Loggers

Logger with Asynchronous I/O.

class mpacklog.async_logger.AsyncLogger(path)

Logger with Asynchronous I/O.

async flush()

Flush messages from the logging queue to file.

async put(message)

Put a new message in the logging queue.

Parameters:

message – New message.

async stop()

Break the loop of the write coroutine.

async write(flush=False)

Continuously write messages from the logging queue to file.

Logger with synchronous I/O.

class mpacklog.sync_logger.SyncLogger(path)

Logger with synchronous I/O.

This logger exposes an API similar to AsyncLogger, but all I/O operations are synchronous.

put(message, write=False)

Puts a message in the queue.

Parameters:
  • message (dict) – message to log

  • write (bool) – whether to append the message to the file immediately

write()

Write all messages in the queue to the file.

This method appends to the file if it already exists.