module OFlow::HasLog
Adds the ability to log by sending log requests to a log Task
.
Public Instance Methods
Logs the message if logging level is at least debug. @param msg [String] message to log
# File lib/oflow/haslog.rb, line 56 def debug(msg) log_msg(:debug, msg, full_name()) end
@return true if debug messages would be logged.
# File lib/oflow/haslog.rb, line 50 def debug?() Env.log_level <= Logger::Severity::DEBUG end
Logs the message if logging level is at least error. @param msg [String] message to display or log
# File lib/oflow/haslog.rb, line 68 def error(msg) log_msg(:error, msg, full_name()) end
@return true if errors would be logged.
# File lib/oflow/haslog.rb, line 35 def error?() Env.log_level <= Logger::Severity::ERROR end
Logs the message if logging level is at least fatal. @param msg [String] message to display or log
# File lib/oflow/haslog.rb, line 80 def fatal(msg) log_msg(:fatal, msg, full_name()) end
Logs the message if logging level is at least info. @param msg [String] message to display or log
# File lib/oflow/haslog.rb, line 62 def info(msg) log_msg(:info, msg, full_name()) end
@return true if info messages would be logged.
# File lib/oflow/haslog.rb, line 45 def info?() Env.log_level <= Logger::Severity::INFO end
Sets the log attribute. @param t [Task] log Task
# File lib/oflow/haslog.rb, line 9 def log=(t) @log = t end
Lower level logging method. Generally only used when one of the primary severity methods are called. @param level [String] message severity or level @param msg [String] message to log @param fn [String] full name of Task
or Flow
calling the log function
# File lib/oflow/haslog.rb, line 18 def log_msg(level, msg, fn) # Abort early if the log severity/level would not log the message. This # also allows non-Loggers to be used in place of the Log Actor. return if Env.log_level > Actors::Log::SEVERITY_MAP[level] lt = log() # To prevent infinite looping, don't allow the logger to log to itself. return if self == lt unless lt.nil? lt.receive(level, Box.new([msg, fn])) else puts "[#{fn}] #{msg}" end end
Logs the message if logging level is at least warn. @param msg [String] message to display or log
# File lib/oflow/haslog.rb, line 74 def warn(msg) log_msg(:warn, msg, full_name()) end
@return true if warn messages would be logged.
# File lib/oflow/haslog.rb, line 40 def warn?() Env.log_level <= Logger::Severity::WARN end