Skip to content

Restore the default logger when plugin loading fails #921

Open

Description

@coderabbitai

Summary

phlex::detail::run in phlex/app/run.cpp captures the default spdlog logger before loading resources, modules, sources, and the driver. A plugin can replace that logger. If a subsequent load throws, run() exits before restoring the captured logger. This can leave an unexpected default logger in place for in-process callers.

Required follow-up

After the project's exception-handling policy is defined, ensure that run() restores its captured default logger when plugin loading fails. Preserve the successful path: restore the logger before spdlog::cfg::load_env_levels() runs. Choose an implementation consistent with the exception-handling policy; a scope guard is one option, not a prescribed solution.

Acceptance criteria

  • A plugin that replaces the default logger followed by a failing component load does not leave the replacement logger installed after the error is handled.
  • Successful loading still restores the captured logger before applying environment log levels.
  • Add regression coverage for the failure path alongside the default-logger plugin test, if feasible under the selected exception-handling policy.

Requested by @knoepfel.
Related PR: #919
Original review comment: #919 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

refactorrefactor and/or cleanup

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions