odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.14k stars 130 forks source link

Custom Log Level Names #489

Closed llchan closed 1 week ago

llchan commented 2 weeks ago

It would be useful to be able to define something like -DQUILL_LOG_LEVEL_NAME_DEBUG=DBG to customize the log level names. Compile-time constants are good enough, no need for runtime configurability as that may incur additional overhead.

odygrd commented 1 week ago

I'd rather steer clear of introducing preprocessor directives to alter the library's behavior. It took considerable effort to eliminate them in the latest version, and they aren't compatible with C++ modules. The only area where I'm permitting their use in the library is LogMacros.h, since even with modules, it must be included due to its macro content.

This has been done in master as runtime, it doesn't seem to have any noticeable difference in performance.

For example:

quill::BackendOptions backend_options;
backend_options.log_level_descriptions[static_cast<uint32_t>(quill::LogLevel::Warning)] = "WARN";
quill::Backend::start(backend_options);
llchan commented 1 week ago

Yep runtime works too if it's now exposed in v5.0.0, thanks! 👍🏼

odygrd commented 1 week ago

Yes it is included in v5.0