How sergiusthebest/plog works
Main Components
• Logger: Central singleton component (with variant “instanceId” support) that collects log records from macro calls.
• Record: Represents the data structure that encapsulates log message details (time, severity, thread id, file name, function name, message, etc.).
• Appender Interface (IAppender) and its concrete implementations:
– File-based appenders (RollingFileAppender)
– Console display (ConsoleAppender and ColorConsoleAppender)
– Platform-specific appenders (AndroidAppender, EventLogAppender, DebugOutputAppender)
– A dynamic container for add/remove operations (DynamicAppender)
• Formatter: Set of classes (TxtFormatter, CsvFormatter, FuncMessageFormatter, MessageOnlyFormatter) that take a Record and produce a formatted output.
• Converter: For example, the UTF8Converter and NativeEOLConverter, responsible for converting a formatted string into a native (binary) output (suitable for file encoding, for instance).
Relationships and Data Flow
• The logging process springs from the logging macros (PLOG, PLOGD, etc.) which construct a Record.
• The Record is passed to the Logger. The Logger (possibly a singleton) holds a list of IAppender pointers.
• Each Appender calls its Formatter’s static “format()” and “header()” functions to transform Record content.
• Then the Appender uses its Converter (if applicable) to convert the text into the appropriate output format (binary or native string encoding).
• Appender outputs the result to their destination (file system, console, platform-specific logs).
Architectural Patterns and Design Principles
• Component separation: There is a clear separation between record construction (Record), message routing (Logger), output formatting (Formatter) and the final output (Appenders and Converters).
• Extensibility: Custom formatters, appenders, and converters can be built easily and plugged in (as shown in the “Extending” section of the README).
• Lazy evaluation: Log streams are evaluated only if the current log level is active, minimizing performance overhead.
Relevant Technologies and Libraries
• This library appears to use templates extensively in its design (e.g., appender classes), so you might indicate parameterized components (like Logger<instanceId>, RollingFileAppender<Formatter, Converter>).