diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-17 11:57:52 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-17 11:57:52 +0100 |
| commit | 48a9df043df64887cb99e03d7613379c947d11d8 (patch) | |
| tree | 897d94bcc55c481a82878c5d2de5ec3369df33ed /src/common.c | |
| parent | a54421dd976fd8081e96c11c2621076876c9986b (diff) | |
| download | BobinkCOpcUa-48a9df043df64887cb99e03d7613379c947d11d8.tar.gz BobinkCOpcUa-48a9df043df64887cb99e03d7613379c947d11d8.zip | |
Add configurable log level as optional CLI argument
All three programs now accept an optional second argument [log-level]
(trace, debug, info, warning, error, fatal) defaulting to info. The
level is applied by setting the logger context pointer directly,
avoiding a memory leak that would occur from overwriting the
heap-allocated logger struct. Also documents the ASan leak-check
workflow in CLAUDE.md.
Diffstat (limited to 'src/common.c')
| -rw-r--r-- | src/common.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c index d102868..7d378f1 100644 --- a/src/common.c +++ b/src/common.c @@ -59,6 +59,26 @@ loadFile (const char *const path) * Security Helpers * ======================================================================== */ +int +parseLogLevel (const char *name) +{ + static const struct + { + const char *name; + UA_LogLevel level; + } levels[] = { + { "trace", UA_LOGLEVEL_TRACE }, { "debug", UA_LOGLEVEL_DEBUG }, + { "info", UA_LOGLEVEL_INFO }, { "warning", UA_LOGLEVEL_WARNING }, + { "error", UA_LOGLEVEL_ERROR }, { "fatal", UA_LOGLEVEL_FATAL }, + }; + for (size_t i = 0; i < sizeof (levels) / sizeof (levels[0]); i++) + { + if (strcmp (name, levels[i].name) == 0) + return (int)levels[i].level; + } + return -1; +} + UA_MessageSecurityMode parseSecurityMode (const char *name) { |
