Interface MongoDBLogWritable

A custom destination for structured logging messages.

interface MongoDBLogWritable {
    write(log: Log): unknown;
}

Methods

Methods

  • This function will be called for every enabled log message.

    It can be sync or async:

    • If it is synchronous it will block the driver from proceeding until this method returns.
    • If it is asynchronous the driver will not await the returned promise. It will attach fulfillment handling (.then). If the promise rejects the logger will write an error message to stderr and stop functioning. If the promise resolves the driver proceeds to the next log message (or waits for new ones to occur).

    Tips:

    • We recommend writing an async write function that never rejects. Instead handle logging errors as necessary to your use case and make the write function a noop, until it can be recovered.
    • The Log messages are structured but subject to change since the intended purpose is informational. Program against this defensively and err on the side of stringifying whatever is passed in to write in some form or another.

    Parameters

    Returns unknown