module
Termisu::Logging
Overview
Logging configuration and lifecycle management.
Handles setup, configuration, and cleanup of the logging system. Called automatically by Termisu.new and Termisu.close.
Defined in:
termisu/log.crConstant Summary
-
FORMATTER =
::Log::Formatter.new do |entry, io| io << (entry.timestamp.to_s("%Y-%m-%d %H:%M:%S.%3N")) io << " [" io << (entry.severity.to_s.upcase.ljust(5)) io << "] " io << entry.source io << ": " io << entry.message if data = entry.context data.each do |key, value| (((io << " ") << key) << "=") << value end end if ex = entry.exception (((io << "\n Exception: ") << ex.class.name) << ": ") << ex.message if bt = ex.backtrace? (bt.first(5)).each do |line| (io << "\n ") << line end end end end -
Custom formatter for Termisu logs
-
LEVELS =
{"trace" => ::Log::Severity::Trace, "debug" => ::Log::Severity::Debug, "info" => ::Log::Severity::Info, "notice" => ::Log::Severity::Notice, "warn" => ::Log::Severity::Warn, "error" => ::Log::Severity::Error, "fatal" => ::Log::Severity::Fatal, "none" => ::Log::Severity::None} -
Severity level name to Log::Severity mapping
Class Method Summary
-
.async_mode=(async_mode : Bool)
Whether async dispatch mode is enabled (affects close behavior)
-
.async_mode? : Bool
Whether async dispatch mode is enabled (affects close behavior)
-
.close
Closes the log file and cleans up resources.
-
.configured=(configured : Bool)
Whether logging has been configured (prevents duplicate setup)
-
.configured? : Bool
Whether logging has been configured (prevents duplicate setup)
-
.flush
Flushes any buffered log entries to disk.
-
.log_file : File | Nil
Open log file handle (nil when logging disabled)
-
.log_file=(log_file : File | Nil)
Open log file handle (nil when logging disabled)
-
.setup
Configures logging based on environment variables.
Class Method Detail
Whether async dispatch mode is enabled (affects close behavior)
Closes the log file and cleans up resources.
In async mode, yields to let the dispatch fiber process pending logs before closing. Called automatically by Termisu.close.
Whether logging has been configured (prevents duplicate setup)
Flushes any buffered log entries to disk.
In async mode, yields first to let dispatch fiber process.
Configures logging based on environment variables.
Reads TERMISU_LOG_LEVEL, TERMISU_LOG_FILE, and TERMISU_LOG_SYNC to configure the logging backend. Called automatically by Termisu.new.
In async mode (default), uses async dispatch with SafeFileIO wrapper. In sync mode, uses direct dispatch for real-time logging.