Table of Contents

Interface ILogHandler

Namespace
OptunaSharp.Logging
Assembly
OptunaSharp.dll

Receives log records emitted through the Optuna logging seam.

public interface ILogHandler

Remarks

One record at a time per handler. OptunaSharp calls Emit(in LogRecord) of one handler instance for one record at a time, under a lock of that instance's own, as Python's logging.Handler.handle holds the handler's lock around emit. A handler therefore needs no lock of its own for what only Emit(in LogRecord) touches; state it shares with other code still needs one. Different handlers run at the same time, on whichever threads log.

Footguns. Emit(in LogRecord) runs on the thread that logged, which may hold any OptunaSharp lock, storage monitors included, and other threads wait for the handler meanwhile. So it must be quick, must not throw (the exception surfaces in the operation that logged), must not call OptunaSharp (a record it logs would re-enter this handler on the same thread), and must not take the Python GIL or wait for another thread that does (THREADING.md ยง5.3).

Methods

Emit(in LogRecord)

Receives a log record synchronously.

void Emit(in LogRecord record)

Parameters

record LogRecord

Log record to deliver to the handler.

Exceptions

Exception

The handler implementation fails; callers do not swallow handler exceptions.