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
-
MUTEX =
Mutex.new(:unchecked)
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)
-
.backend : ::Log::IOBackend | Nil
Installed backend (nil when logging disabled or closed)
-
.backend=(backend : ::Log::IOBackend | Nil)
Installed backend (nil when logging disabled or closed)
-
.close : Nil
Unbinds Termisu loggers before draining their backend, then flushes and closes the file.
-
.configured=(configured : Bool)
Whether logging has been configured (prevents duplicate setup)
-
.configured? : Bool
Whether logging has been configured (prevents duplicate setup)
-
.flush : Nil
Drains all entries accepted before this call and flushes the file buffer.
-
.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 : Nil
Configures logging based on environment variables.
Class Method Detail
Whether async dispatch mode is enabled (affects close behavior)
Installed backend (nil when logging disabled or closed)
Unbinds Termisu loggers before draining their backend, then flushes and closes the file. Every cleanup step runs and the first error is re-raised.
Whether logging has been configured (prevents duplicate setup)
Configures logging based on environment variables.
Setup failures retain the existing best-effort behavior: Termisu remains usable with its isolated loggers disabled.