-
Notifications
You must be signed in to change notification settings - Fork 2
Custom Backends
logme allows users to implement custom backends.
A custom backend can be used to:
- Capture log output for testing
- Forward logs to external systems
- Implement application-specific storage
Custom backends:
- Implement the backend interface
- Can be attached to any channel
- Participate in normal routing
A reference implementation of a custom backend is provided in the test suite (TestBackend).
This backend is used to validate routing, filtering, and message delivery behavior in automated tests.
To implement your own backend, create a class derived from Logme::Backend and implement at minimum the following method:
virtual void Display(Context& context, const char* line) = 0;Inside Display, to obtain a fully prepared log line (with formatting, timestamps, prefixes, etc.), call Context::Apply:
int nc;
const char* buffer = context.Apply(Owner, Owner->GetFlags(), line, nc);The returned buffer is always null-terminated. The nc value contains the length of the buffer (equivalent to strlen(buffer)).
The resulting string can then be written to a file, sent over the network, stored in memory, or otherwise processed according to the backend’s purpose.
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme