-
Notifications
You must be signed in to change notification settings - Fork 3
Control Policies
Control policies restrict which control commands are allowed for a particular control API call path.
The policy mechanism exists so that powerful control commands can be reused safely from different sources. For example, startup environment control can allow level and trace changes while rejecting file backend changes.
#include <Logme/Logme.h>
#include <Logme/ControlPolicy.h>
std::string response = Logme::Instance->Control(
"level --channel net debug",
Logme::ControlPolicy::Safe()
);The old overload remains available:
std::string response = Logme::Instance->Control("help");It uses full control for backward compatibility.
Allows the normal unrestricted control surface. This is the behavior of the original Logger::Control(command) overload and the compatibility default.
Designed for conservative diagnostics. It allows:
- level changes
- output flag changes
- trace point commands
- subsystem filtering commands
- non-sensitive informational commands such as help/version/list/overview/channel inspection
It rejects:
- extension commands
logs- backend changes
- file backend changes
- channel creation/deletion
- channel routing changes
- error-channel changes
This is the default policy used by Environment Control.
Starts from Safe() and additionally allows backend changes.
The policy still keeps AllowFileBackends disabled by default, so it is intended for temporary diagnostic backends such as console, debugger, buffer, or ring buffer rather than arbitrary file output.
A policy object can be customized directly:
Logme::ControlPolicy policy = Logme::ControlPolicy::Diagnostic();
policy.AllowFileBackends = true;
policy.AllowLogsCommand = false;
policy.AllowExtensions = false;
std::string response = Logme::Instance->Control(command, policy);Available switches include:
AllowExtensionsAllowLogsCommandAllowFormatCommandAllowFileBackendsAllowChannelCreateDeleteAllowChannelRoutingAllowChannelErrorAllowBackendChangesAllowLevelChangesAllowFlagChangesAllowTraceChangesAllowSubsystemChanges
Use a custom policy when the built-in Safe, Diagnostic, and Full presets do not match the trust level of a command source.
Policy is checked before command execution. Extension commands are also subject to policy: if extensions are not allowed, the extension handler is not called.
Rejected commands return an error response and are logged through the normal internal diagnostics path when used by environment control.
Policy does not make a control command transactional. If a source executes several commands and a later command is rejected, earlier successful commands remain applied.
The policy-aware overload is a programmatic API. Existing control-server behavior is preserved for compatibility unless the application explicitly routes a command source through a policy-aware path.
Use Security and Control Server recommendations when exposing network control. Use Environment Control for startup overrides driven by environment variables.
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme
- Home
- Getting Started
- Why logme?
- Core Concepts
- Logging Macros
- Fatal Handling
- Crash Logging
- glog Compatibility
- C API
- Choosing Logging Macros
- Function tracing
- Trace Points
- Override Scopes
- Advanced Features
- Collapse Logging
- Feature Map
- Overview
- Console Backend
- Debugger Backend
- File Backend
- File Rotation & Retention
- Buffer Backend
- Ring Buffer Backend
- SharedFile Backend
- Callback Backend
- Windows Event Log Backend
- Custom Backends
- Runtime Control
- Configuration
- Configuration JSON
- Control Server
- Environment Control
- Control Policies
- Trace Points
- Message Filtering