class QB::IPC::STDIO::Server::LogService
QB
STDIO Service to receive log lines in JSON format and forward them on to the logger.
Public Class Methods
new(name:, socket_dir: super name: name, socket_dir: socket_dir)
click to toggle source
# File lib/qb/ipc/stdio/server/log_service.rb, line 91 def initialize name:, socket_dir: super name: name, socket_dir: socket_dir @loggers = {} end
Public Instance Methods
work_in_thread()
click to toggle source
# File lib/qb/ipc/stdio/server/log_service.rb, line 96 def work_in_thread while (line = @socket.gets) do logger.trace "received line", line: line load_log_in_thread line end end
Protected Instance Methods
load_log_in_thread(line)
click to toggle source
Try to load the line into a {SemanticLogger::Log} instance.
# File lib/qb/ipc/stdio/server/log_service.rb, line 140 def load_log_in_thread line # logger.with_level :trace do decoded = logger.catch.warn( "Unable to decode log message", line: line, ) { ActiveSupport::JSON.decode line } logger.trace "Decoded log message", decoded return nil unless decoded logger.catch.warn( "Unable to process log message", line: line, decoded: decoded, ) do log = Log.new **decoded.to_options logger.trace "Constructed {Log}", log: log write_log log end # logger.catch.warn # end # logger.with_level :trace end
logger_for(name)
click to toggle source
Get a {NRSER::Log::Logger} for a log name, creating them on demand and caching after that.
@param [String] name
Name from the log message.
@return [NRSER::Log::Logger]
# File lib/qb/ipc/stdio/server/log_service.rb, line 117 def logger_for name @loggers[name] ||= NRSER::Log[name] end
write_log(log)
click to toggle source
Log
a {Log} in it's logger if it should log.
@protected
@param [Log] log
Log instance to dispatch
@return [void]
# File lib/qb/ipc/stdio/server/log_service.rb, line 131 def write_log log logger = logger_for log.name # logger.level = :trace logger.log( log ) if logger.should_log?( log ) end