Turn off sending events for the LOCAL interface to the system log.

This commit is contained in:
Vitaly Baranov 2021-11-03 16:14:40 +03:00
parent bdf640326b
commit 49d8360fc5
2 changed files with 7 additions and 0 deletions

View File

@ -246,6 +246,7 @@ void Session::shutdownNamedSessions()
Session::Session(const ContextPtr & global_context_, ClientInfo::Interface interface_)
: auth_id(UUIDHelpers::generateV4()),
global_context(global_context_),
interface(interface_),
log(&Poco::Logger::get(String{magic_enum::enum_name(interface_)} + "-Session"))
{
prepared_client_info.emplace();
@ -418,6 +419,11 @@ ContextMutablePtr Session::makeQueryContext(ClientInfo && query_client_info) con
std::shared_ptr<SessionLog> Session::getSessionLog() const
{
/// For the LOCAL interface we don't send events to the session log
/// because the LOCAL interface is internal, it does nothing with networking.
if (interface == ClientInfo::Interface::LOCAL)
return nullptr;
// take it from global context, since it outlives the Session and always available.
// please note that server may have session_log disabled, hence this may return nullptr.
return global_context->getSessionLog();

View File

@ -79,6 +79,7 @@ private:
mutable bool notified_session_log_about_login = false;
const UUID auth_id;
const ContextPtr global_context;
const ClientInfo::Interface interface;
/// ClientInfo that will be copied to a session context when it's created.
std::optional<ClientInfo> prepared_client_info;