Skip to content

Logs may be discarded if the program exits before AsyncDrain can write #114

@tsheinen

Description

@tsheinen

slog-async drains will attempt to flush and join the writer thread on drop. Foundations holds a reference to the async drain in a static OnceCell so it's never dropped. This means that if a program logs and then exits the writer thread will not be joined and that log might not be written.

I'm thinking the least surprising solution is to just hook atexit and make sure it gets dropped with some changes to HARNESS to have sufficient interior mutability.

slog-async also offers AsyncGuard which when dropped will tell the async thread to finish and then join on it. That could be added to TelemetryDriver or something to make sure the logs get flushed when it goes out of scope. IMO given currently logger semantics (stored globally, may only be called once, etc) it's simpler to just flush it on exit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions