Skip to content

Integration with quill logging library#77107

Closed
antonio2368 wants to merge 62 commits intomasterfrom
logging-quill
Closed

Integration with quill logging library#77107
antonio2368 wants to merge 62 commits intomasterfrom
logging-quill

Conversation

@antonio2368
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

https://github.com/odygrd/quill

There are some things still missing like syslog but most of the functionalities should be supported as before.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 4, 2025

Workflow [PR], commit [5394230]

@clickhouse-gh clickhouse-gh bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Mar 4, 2025
@antonio2368
Copy link
Copy Markdown
Member Author

antonio2368 commented Mar 4, 2025

@maxknv why aren't my changes in ci/jobs/fast_test.py picked up?

@maxknv
Copy link
Copy Markdown
Member

maxknv commented Mar 4, 2025

@maxknv why aren't my changes in ci/jobs/fast_test.py picked up?

because of fasttest's build script design. if module is required for fasttest build you need to add it into this array: https://github.com/ClickHouse/ClickHouse/blob/master/tests/docker_scripts/fasttest_runner.sh#L122

@azat azat self-assigned this Mar 5, 2025
@Algunenano Algunenano self-assigned this Mar 21, 2025
Copy link
Copy Markdown
Member

@Algunenano Algunenano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a few comments now but I'll continue reviewing

${LIBRARY_DIR}/include/quill/backend/TransitEventBuffer.h
${LIBRARY_DIR}/include/quill/backend/BackendUtilities.h

${LIBRARY_DIR}/include/quill/bundled/fmt/args.h
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this won't cause issues with our own bundled fmt if/when the versions don't match exactly

Copy link
Copy Markdown

@odygrd odygrd Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quill bundles libfmt under a custom namespace and uses its header-only version internally.

There shouldn't be any issues if you're using a different libfmt external version. The only potential for ABI incompatibilities arises if you reuse existing fmt formatters for custom types with Quill (see external fmt formatter specializations).

However, I didn’t see that being used in this PR, so you should be fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use custom formatters that AFAIK we format everything before passing it to Quill (at least we do for other loggers). But maybe @antonio2368 can confirm this is still the case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt is still used in background thread regardless where we do the main formatting.

{
queue.reserve(settings.reserved_size_rows);

if (settings.turn_off_logger)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Is this missing / removed?

Copy link
Copy Markdown
Member

@Algunenano Algunenano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor stuff. Still need to review some large diffs (the logger changes themselves 😄), understand the cmake changes and the tests changes too

/// This wrapper helps to avoid too frequent and noisy log messages.
/// For each pair (logger_name, format_string) it remembers when such a message was logged the last time.
/// The message will not be logged again if less than min_interval_s seconds passed since the previously logged message.
class LogFrequencyLimiterImpl
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can move this and LogSeriesLimiter to a different file to remove deps from Logger.h? I know it was in a bad place already.

Copy link
Copy Markdown
Member

@Algunenano Algunenano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final batch of comments. Great job

LoggerPtr getLogger(std::string name, LoggerComponent component = LoggerComponent::Root);

template <size_t n>
LoggerPtr getLogger(const char (&name)[n])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can put getLogger into Logger_fwd.h since it seems it's what most includes for Common/Logger.h are for. That way we avoid including some heavy headers

__LINE__, \
_format_string, \
_format_string_args); \
DB::ExtendedLogMessage _msg_ext = DB::ExtendedLogMessage::getFrom(_poco_message); \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_msg_ext should be built after _should_log so we don't build it unnecessarily under LogFrequency or LogSeries

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it for text log also later


auto current_logger = config.getString("logger", "");
if (config_logger.has_value() && *config_logger == current_logger)
if (config_logger.has_value())// && *config_logger == current_logger)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd and maybe a leftover. Does this mean we can't change the config of the logger at runtime and, for example, change the log level?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a hack, so I added initialized flag.
We can't change loggers at runtime, we can only change levels but this is handled by function updateLevels below.

error_log_file = std::static_pointer_cast<DB::RotatingFileSink>(sink);
}

// if (config.getBool("logger.use_syslog", false))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to delete this code and drop syslog support as part of this PR.

}
}
}
// // Set level and channel to all already created loggers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted code

}
}
}
getRootLogger()->setLogLevel(min_log_level);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More deleted code

#ifndef WITHOUT_TEXT_LOG
auto logs_queue = CurrentThread::getInternalTextLogsQueue();

/// Log to "TCP queue" if message is not too noisy
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's TCP queue? Is it for client logs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing this comes and replaces OwnSplitChannel

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jun 10, 2025

Dear @antonio2368, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 19, 2025

Dear @antonio2368, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

1 similar comment
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 26, 2025

Dear @antonio2368, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message.

@alexey-milovidov
Copy link
Copy Markdown
Member

Not relevant after @Algunenano improved the logger.

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

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants