Loading...
Searching...
No Matches
by::logger Class Reference

Main logging interface for the byeol language system. More...

#include <logger.hpp>

Inheritance diagram for by::logger:
by::stream

Public Member Functions

streamgetStream (nidx n)
 
const streamgetStream (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 filtersgetFilters () 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 loggerget ()
 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
 

Detailed Description

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.

Usage

Basic usage with macros:

BY_I("pods[%s] origins loaded.", getName());

This produces output like:

Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34

The log shows:

  1. Date (Oct 22 2025) and time (21:26:13)
  2. Log level (I for Info) - ERR, WARN, INFO are available
  3. Class name (cppPodLoading, abbreviated)
  4. Function (_loadLibs) and line number (49)
  5. Log message (pod[cpp] origins loaded)

stream

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:

RELEASED ---init()---> INITIALIZED
RELEASED <--rel()----- INITIALIZED

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.

macro

Use logging macros for advanced features like filename, function name, and line numbers:

BY_I("just message.");
BY_DE("leaf: ERR: %s", e); // Debug-only error log with format specifiers

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).

richLog

The richLog feature uses polymorphism to convert format specifier arguments to appropriate types:

BY_I("make a closure for %s.%s", meObj, cast.getSrc().getName());

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.

filterable

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.

Member Function Documentation

◆ getName()

const std::string & by::logger::getName ( ) const
overridevirtual

Implements by::stream.

◆ isInit()

nbool by::logger::isInit ( ) const
overridevirtual

Reimplemented from by::stream.

◆ log()

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.

Returns
true on success, false on error

◆ logBypass()

nbool by::logger::logBypass ( const nchar * message)
overridevirtual

Log message bypassing normal filtering.

Returns
true on success, false on error

Reimplemented from by::stream.

◆ logFormatBypass()

nbool by::logger::logFormatBypass ( const nchar * fmt,
... )

Logs formatted message bypassing rich logging conversion.

Returns
true on success, false on error

◆ pushStream() [1/2]

nbool by::logger::pushStream ( stream & new_stream)

Adds a new logging stream to the logger.

Parameters
new_streamReference to the stream to add.
Returns
true on success, false on error (e.g., stream already added or invalid).

◆ pushStream() [2/2]

nbool by::logger::pushStream ( stream * new_stream)

Adds a new logging stream to the logger.

Returns
true on success, false on error

Adds a new logging stream to the logger.

Parameters
new_streamPointer to the stream to add.
Returns
true on success, false on error (e.g., stream already added or invalid).

◆ setEnable()

void by::logger::setEnable ( nbool enable)
overridevirtual

Reimplemented from by::stream.


The documentation for this class was generated from the following file: