8000 Use fmt::format for loggers · Issue #1026 · cabinpkg/cabin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Use fmt::format for loggers #1026
Closed
@ken-matsui

Description

@ken-matsui

https://github.com/poac-dev/poac/blob/23471b6c352809dff0d0655cbb47586e1c8e3358/src/Logger.hpp

For error, warn, info, debug, and trace, we'd like to use fmt::format style formatting instead of std::ostream (internal implementation details). For example, the following usage is not that clear:

https://github.com/poac-dev/poac/blob/23471b6c352809dff0d0655cbb47586e1c8e3358/src/main.cc#L94-L96

We may want to do like this instead:

logger::error(
    "'poac {}' failed with exit code `{}`", *itr, exitCode
 ); 

We can use fmt::format for arguments to these loggers and we do, but the new interface will be clearer:

https://github.com/poac-dev/poac/blob/23471b6c352809dff0d0655cbb47586e1c8e3358/src/Cmd/Build.cc#L52-L58

logger::info can be:

logger::info( 
    "Compiling", "{} v{} ({})", packageName,
    getPackageVersion().toString(),
    getProjectBasePath().string()
);

Theoretically, error, warn, debug, and trace's function arguments would be like:

(fmt::format_string<T...> fmt, T&&... args)

And info has:

(std::string_view header, fmt::format_string<T...> fmt, T&&... args)

Note that the actual implementation may be different as to conform to the current implementation style.

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

      0