Interface LogWriterFunc

All Superinterfaces:
FunctionPointer
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface @Generated("org.javagi.JavaGI") public interface LogWriterFunc extends FunctionPointer

Functional interface declaration of the LogWriterFunc callback.

See Also:
  • Method Details

    • run

      LogWriterOutput run(Set<LogLevelFlags> logLevel, @Nullable LogField @Nullable [] fields)

      Writer function for log entries. A log entry is a collection of one or more GLogFields, using the standard field names from journal specification. See g_log_structured() for more information.

      Writer functions must ignore fields which they do not recognise, unless they can write arbitrary binary output, as field values may be arbitrary binary.

      logLevel is guaranteed to be included in fields as the PRIORITY field, but is provided separately for convenience of deciding whether or where to output the log entry.

      Writer functions should return LogWriterOutput.HANDLED if they handled the log message successfully or if they deliberately ignored it. If there was an error handling the message (for example, if the writer function is meant to send messages to a remote logging server and there is a network error), it should return LogWriterOutput.UNHANDLED. This allows writer functions to be chained and fall back to simpler handlers in case of failure.

      Parameters:
      logLevel - log level of the message
      fields - fields forming the message
      Returns:
      LogWriterOutput.HANDLED if the log entry was handled successfully; LogWriterOutput.UNHANDLED otherwise
      Since:
      2.50
    • upcall

      default int upcall(int logLevel, MemorySegment fields, long nFields, MemorySegment userData)
      The upcall method is called from native code. The parameters are marshaled and run(Set, LogField[]) is executed.
    • toCallback

      default MemorySegment toCallback(Arena arena)
      Creates a native function pointer to the upcall(int, MemorySegment, long, MemorySegment) method.
      Specified by:
      toCallback in interface FunctionPointer
      Parameters:
      arena - the arena in which the function pointer is allocated
      Returns:
      the native function pointer