Skip to content

Make the global logger thread local #81

@raphaelcohn

Description

@raphaelcohn

It'd be very useful to have the global logger be init'd so it is thread local. This could be a significant breaking change to library users, so I'd suggest it was done using a compile-time feature.

Why?

  1. Occasionally, logging can be quite expensive for some binaries, particularly if they are using one of the newer cloud services. In this world, one runs a second logging thread and has log requests forwarded to it (eg using thread::mpsc).
  2. For larger server projects, logging needs may also vary for different parts of the code base:-
    • The main thread is used only for startup, option parsing and shutdown, and has very little in the way of logging needs, but if it does log, should log to standard error
    • The main application threads (eg socket listeners) need to log to a monitored cloud service, so pass their logging requests to a third logging thread
    • The logging thread receives log requests and forwards them on. It itself may need a logger that talks, say, to local syslog.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions