diff --git a/documentation/ioc.rst b/documentation/ioc.rst index d9bfd13..190bef6 100644 --- a/documentation/ioc.rst +++ b/documentation/ioc.rst @@ -37,6 +37,20 @@ served by the Integrated PVA server. Print information about module versions, target, and toolchain. May be requested when reporting a bug. +.. cpp:function:: void pvxs_log_config(const char *config) + + Enable additional :ref:`logconfig` as if more comma separated key=VALUE pairs + were appended to the **$PVXS_LOG** environment variable. + + Since UNRELEASED + +.. cpp:function:: void pvxs_log_reset() + + Reset logging to defaults. Negates the effects of **$PVXS_LOG** and later + configuration. + + Since UNRELEASED + Adding custom PVs to Server --------------------------- diff --git a/documentation/util.rst b/documentation/util.rst index 68a8137..5e7ff1e 100644 --- a/documentation/util.rst +++ b/documentation/util.rst @@ -23,6 +23,11 @@ To enable all logging at full detail. :: export PVXS_LOG="*=DEBUG" +To enable all internal logging at INFO detail, +and any entries with the prefix "pvxs.foo*" at DEBUG detail. :: + + export PVXS_LOG="pvxs.*=INFO,pvxs.foo*=DEBUG" + .. doxygenenum:: pvxs::Level Controlling Logging diff --git a/ioc/iochooks.cpp b/ioc/iochooks.cpp index fe50e6d..ae0455d 100644 --- a/ioc/iochooks.cpp +++ b/ioc/iochooks.cpp @@ -165,9 +165,17 @@ void testCleanupPrepare() resetGroups(); } -//////////////////////////////////// -// Two ioc shell commands for pvxs -//////////////////////////////////// +static +void pvxs_log_config(const char *str) +{ + logger_config_str(str); +} + +static +void pvxs_log_reset() +{ + logger_level_clear(); +} /** * Show the PVXS server report. @@ -456,6 +464,12 @@ void pvxsBaseRegistrar() noexcept { bool enableQ = enable2(); + IOCShCommand("pvxs_log_config", "KEY=VAL,KEY=VAL,...", + "Append logger configuration. eg. pvxs_log_config \"pvxs.*=DEBUG\"") + .implementation<&pvxs_log_config>(); + IOCShCommand<>("pvxs_log_clear", + "Reset logger configuration to defaults") + .implementation<&pvxs_log_reset>(); IOCShCommand("pvxsr", "[show_detailed_information?]", "PVXS Server Report. " "Shows information about server config (level==0)\n" "or about connected clients (level>0).\n") diff --git a/src/log.cpp b/src/log.cpp index 46e4952..b3d3afc 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -340,12 +340,8 @@ void logger_level_clear() logger_gbl->config.clear(); } -void logger_config_env() +void logger_config_str(const char *env) { - const char *env = getenv("PVXS_LOG"); - if(!env || !*env) - return; - threadOnce<&logger_prepare>(); Guard G(logger_gbl->lock); @@ -389,6 +385,15 @@ void logger_config_env() errlogFlush(); } +void logger_config_env() +{ + const char *env = getenv("PVXS_LOG"); + if(!env || !*env) + return; + + logger_config_str(env); +} + } // namespace pvxs namespace pvxs {namespace impl { diff --git a/src/utilpvt.h b/src/utilpvt.h index e8ffb81..fd7a261 100644 --- a/src/utilpvt.h +++ b/src/utilpvt.h @@ -252,6 +252,9 @@ using aligned_union = std::aligned_union; } // namespace impl using namespace impl; +PVXS_API +void logger_config_str(const char *env); + inline timeval totv(double t) {