aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-09-22 10:04:02 -0400
committerGitHub <[email protected]>2023-09-22 16:04:02 +0200
commit47ba787e2cfe32b252b74e09494fbcaabc4e8190 (patch)
tree80acc5dfa51b08211583e38d31be2b2327a525a3 /src/zenserver/cache/structuredcachestore.cpp
parentadded support for sln on Mac (#421) (diff)
downloadzen-47ba787e2cfe32b252b74e09494fbcaabc4e8190.tar.xz
zen-47ba787e2cfe32b252b74e09494fbcaabc4e8190.zip
Add runtime status/control of logging (#419)
- Feature: New endpoint `/admin/logs` to query status of logging and log file locations and cache logging - `enablewritelog`=`true`/`false` parameter to control cache write logging - `enableaccesslog`=`true`/`false` parameter to control cache access logging - `loglevel` = `trace`/`debug`/`info`/`warning`/`error` - Feature: New zen command `logs` to query/control zen logging - No arguments gives status of logging and paths to log files - `--cache-write-log` `enable`/`disable` to control cache write logging - `--cache-access-log` `enable`/`disable` to control cache access logging - `--loglevel` `trace`/`debug`/`info`/`warning`/`error` to set debug level
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.cpp')
-rw-r--r--src/zenserver/cache/structuredcachestore.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp
index 4499b05f7..809df1a94 100644
--- a/src/zenserver/cache/structuredcachestore.cpp
+++ b/src/zenserver/cache/structuredcachestore.cpp
@@ -238,10 +238,7 @@ ZenCacheStore::ZenCacheStore(GcManager& Gc, const Configuration& Configuration,
, m_Configuration(Configuration)
, m_ExitLogging(false)
{
- if (m_Configuration.EnableAccessLog || m_Configuration.EnableWriteLog)
- {
- m_AsyncLoggingThread = std::thread(&ZenCacheStore::LogWorker, this);
- }
+ SetLoggingConfig(m_Configuration.Logging);
CreateDirectories(m_Configuration.BasePath);
ZEN_INFO("Initializing at '{}'", m_Configuration.BasePath);
@@ -281,12 +278,7 @@ ZenCacheStore::ZenCacheStore(GcManager& Gc, const Configuration& Configuration,
ZenCacheStore::~ZenCacheStore()
{
- m_ExitLogging.store(true);
- m_LogEvent.Set();
- if (m_AsyncLoggingThread.joinable())
- {
- m_AsyncLoggingThread.join();
- }
+ SetLoggingConfig({.EnableWriteLog = false, .EnableAccessLog = false});
m_Namespaces.clear();
}
@@ -381,7 +373,7 @@ ZenCacheStore::Get(const CacheRequestContext& Context,
{
bool Result = Store->Get(Bucket, HashKey, OutValue);
- if (m_Configuration.EnableAccessLog)
+ if (m_AccessLogEnabled)
{
ZEN_TRACE_CPU("Z$::Get::AccessLog");
bool Signal = false;
@@ -421,7 +413,7 @@ ZenCacheStore::Put(const CacheRequestContext& Context,
{
ZEN_TRACE_CPU("Z$::Put");
- if (m_Configuration.EnableWriteLog)
+ if (m_WriteLogEnabled)
{
ZEN_TRACE_CPU("Z$::Get::WriteLog");
bool Signal = false;
@@ -616,6 +608,31 @@ ZenCacheStore::StorageSize() const
return Size;
}
+void
+ZenCacheStore::SetLoggingConfig(const Configuration::LogConfig& Loggingconfig)
+{
+ if (!Loggingconfig.EnableAccessLog && !Loggingconfig.EnableWriteLog)
+ {
+ m_AccessLogEnabled.store(false);
+ m_WriteLogEnabled.store(false);
+ m_ExitLogging.store(true);
+ m_LogEvent.Set();
+ if (m_AsyncLoggingThread.joinable())
+ {
+ m_AsyncLoggingThread.join();
+ }
+ m_Configuration.Logging = Loggingconfig;
+ return;
+ }
+ if (!m_AccessLogEnabled.load() && !m_WriteLogEnabled.load())
+ {
+ m_AsyncLoggingThread = std::thread(&ZenCacheStore::LogWorker, this);
+ }
+ m_WriteLogEnabled.store(Loggingconfig.EnableWriteLog);
+ m_AccessLogEnabled.store(Loggingconfig.EnableAccessLog);
+ m_Configuration.Logging = Loggingconfig;
+}
+
ZenCacheStore::Info
ZenCacheStore::GetInfo() const
{