-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started
logme can be used immediately without any configuration, or gradually extended to a fully dynamic setup.
This page describes the three main usage models.
If the application does not configure logme explicitly, a default channel is created automatically.
Default behavior:
- A default channel exists
- Console output is enabled
- Debugger output is enabled on Windows (only in Debug builds)
- Reasonable formatting and severity filtering is applied
This setup is often sufficient for:
- Small tools
- Utilities
- Early development stages
In this model, channels and backends are created explicitly in code.
Typical use cases:
- Highly constrained environments
- Applications with fixed logging topology
- Custom backend logic
#include <Logme/Logme.h>
#include <Logme/Backend/ConsoleBackend.h>
int main()
{
auto root = Logme::Instance->CreateChannel("root");
root->AddBackend(std::make_shared<ConsoleBackend>(root));
auto http = Logme::Instance->CreateChannel("http");
http->AddLink(root);
// Goes to http backends (if any), then to root
fLogmeI(http, "GET {} -> {}", "/index.html", 200);
return 0;
}In this model, the entire logging topology is described in a JSON configuration file.
Advantages:
- No recompilation required
- Runtime reconfiguration
- Suitable for production systems
JSON configuration can be reloaded dynamically.
This configuration creates the following logging setup:
-
A default channel (channel with an empty name
"") is created.- The log level is set to Info, meaning all messages except Debug are allowed.
- Three backends are attached to this channel:
- ConsoleBackend — always enabled.
- DebugBackend — created only on Windows and only in Debug builds.
-
FileBackend — opens
log.txtin append mode (existing log is preserved). The file path is relative and the file is created inside the logger home directory specified viaLogger::SetHomeDirectory().
-
A channel named
httpis created.- This channel has no backends of its own.
- It is linked to the default channel, so all messages written to
httpare forwarded to the default channel and processed by its backends.
{
"channels": [
{
"name": "",
"level": "info",
"backends": [
{ "type": "ConsoleBackend" },
{
"type": "DebugBackend",
"platform": "windows",
"build": "debug"
},
{
"type": "FileBackend",
"file": "log.txt",
"append": true
}
]
},
{
"name": "http",
"link": ""
}
]
}logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme