Skip to content

Commit

Permalink
use ANSI colour codes universally in ConsoleSink
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed Nov 3, 2024
1 parent d8015ba commit e6415fc
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 419 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@
- [v1.1.0](#v110)
- [v1.0.0](#v100)

## v8.0.0

- Unified `JsonFileSink.h` and `JsonConsoleSink.h` into a single header, `JsonSink.h`, with both classes now sharing a
common implementation
- Users can now inherit from `JsonFileSink` or `JsonConsoleSink` and override the `generate_json_message(...)` function
to implement their own custom JSON log formats
- Simplified `ConsoleSink` by applying ANSI colour codes universally across all platforms, including Windows. The
previous Windows-specific implementation has been removed. Note that `quill::ConsoleColours` has been replaced with
`quill::ConsoleSink::Colours`, and `quill::ConsoleColours::ColourMode` has been renamed to
`quill::ConsoleSink::ColourMode`.

## v7.5.0

- In previous versions, logging on Windows automatically included `windows.h` in all components. The frontend will no
Expand Down Expand Up @@ -121,6 +132,7 @@
```cpp
quill::Frontend::create_or_get_sink<quill::ConsoleSink>(
"sink_id_1", quill::ConsoleColours::ColourMode::Automatic);
```

## v7.3.0

Expand Down
2 changes: 1 addition & 1 deletion examples/console_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main()

// Frontend
auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>(
"sink_id_1", quill::ConsoleColours::ColourMode::Automatic);
"sink_id_1", quill::ConsoleSink::ColourMode::Automatic);

quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink));

Expand Down
9 changes: 4 additions & 5 deletions examples/custom_console_colours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ int main()
quill::Backend::start(backend_options);

// Frontend
quill::ConsoleColours custom_console_colours;
custom_console_colours.set_default_colours();
custom_console_colours.set_colour(quill::LogLevel::Info, quill::ConsoleColours::blue); // overwrite the colour for INFO
quill::ConsoleSink::Colours colours;
colours.apply_default_colours();
colours.assign_colour_to_log_level(quill::LogLevel::Info, quill::ConsoleSink::Colours::blue); // overwrite the colour for INFO

// Create the sink
auto console_sink =
quill::Frontend::create_or_get_sink<quill::ConsoleSink>("sink_id_1", custom_console_colours);
auto console_sink = quill::Frontend::create_or_get_sink<quill::ConsoleSink>("sink_id_1", colours);

quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ConsoleSinkWithFormatter : public quill::ConsoleSink
{
public:
ConsoleSinkWithFormatter(quill::PatternFormatterOptions const& pattern_formater_options,
bool enable_colours = true, std::string const& stream = "stdout")
: quill::ConsoleSink(enable_colours, stream), _formatter(pattern_formater_options)
quill::ConsoleSink::ColourMode colour_mode = quill::ConsoleSink::ColourMode::Automatic,
std::string const& stream = "stdout")
: quill::ConsoleSink(colour_mode, stream), _formatter(pattern_formater_options)
{
}

Expand Down
Loading

0 comments on commit e6415fc

Please sign in to comment.