Main logging interface for the byeol language system. More...
#include <logger.hpp>
Public Member Functions | |
| stream * | getStream (nidx n) |
| const stream * | getStream (nidx n) const BY_CONST_FUNC(getStream(n)) stream *getStream(const nchar *msg) |
| void | setEnable (nbool enable) override |
| enables | getEnables () const |
| void | setEnables (const enables &enbs) |
| ncnt | getStreamCount () const |
| nbool | logFormatBypass (const nchar *fmt,...) |
| Logs formatted message bypassing rich logging conversion. | |
| nbool | log (errLv::level lv, const std::string &filename, const nchar *func, int line, const nchar *fmt,...) |
| Main logging function with full context information. | |
| nbool | pushStream (stream *new_stream) |
| Adds a new logging stream to the logger. | |
| nbool | pushStream (stream &new_stream) |
| Adds a new logging stream to the logger. | |
| const std::string & | getName () const override |
| nbool | logBypass (const nchar *message) override |
| Log message bypassing normal filtering. | |
| nbool | isInit () const override |
| void | setFilters (const filters &newFilters) |
| Set logging filters. | |
| void | setFilters () |
| Reset filters to default. | |
| const filters & | getFilters () const |
Public Member Functions inherited from by::stream | |
| stream (nbool isEnable=true) | |
| nbool | logBypass (const std::string &message) |
| nbool | isNull () const |
| Checks if this stream is a null object. | |
| virtual nbool | isEnable () const |
Static Public Member Functions | |
| static logger & | get () |
| Get singleton logger instance. | |
Public Attributes | |
| const stream *getStream(const nchar *msg) const BY_CONST_FUNC(getStream(msg)) stream *getStream(const std const stream | getStream )(const std::string &msg) const BY_CONST_FUNC(getStream(msg)) nbool isEnable() const override |
Main logging interface for the byeol language system.
A lightweight C++ logging framework facade that enables systematic logging through multiple logging destinations called stream. Typically used through accompanying macros.
Basic usage with macros:
This produces output like:
The log shows:
The core of the clog module is stream. A stream represents the logging output destination. Currently consoleStream and fileLogStream exist. All streams are owned by the logger class from the start.
Each stream follows the standard byeol state diagram:
Streams also manage enable status. Using setEnable(false) disables a specific stream. The logger class itself inherits from stream, so it provides the same API. Logger redirects each API call to all owned streams. For example, logger::get().setEnable(false) disables all streams.
Use logging macros for advanced features like filename, function name, and line numbers:
Macros follow byeol convention with BY_ prefix, followed by log level (E/W/I). Add D prefix for debug-only logs (e.g., BY_DE, BY_DW, BY_DI).
The richLog feature uses polymorphism to convert format specifier arguments to appropriate types:
Output: Oct 22 2025 22:01:12 I closure <_make#73> make a closure for obj.foo
Both tstr<obj> and std::string are properly converted to strings. Since clog is a low-level module in the architecture, richLog is defined per-module to handle module-specific class conversions.
Log messages can be filtered based on specific conditions. The filterable interface's filt() function determines filtering. Add filters using setFilters(const filters&). For example, errPassFilter only passes ERR level messages.
|
overridevirtual |
Implements by::stream.
|
overridevirtual |
Reimplemented from by::stream.
| nbool by::logger::log | ( | errLv::level | lv, |
| const std::string & | filename, | ||
| const nchar * | func, | ||
| int | line, | ||
| const nchar * | fmt, | ||
| ... ) |
Main logging function with full context information.
Log message bypassing normal filtering.
Reimplemented from by::stream.
Logs formatted message bypassing rich logging conversion.
Adds a new logging stream to the logger.
| new_stream | Reference to the stream to add. |
Adds a new logging stream to the logger.
Adds a new logging stream to the logger.
| new_stream | Pointer to the stream to add. |
Reimplemented from by::stream.