Class: ROS::LocalLogger
- Inherits:
-
Object
- Object
- ROS::LocalLogger
- Defined in:
- lib/ros/log.rb
Overview
Logger for local output
output with color escape sequence
Instance Method Summary (collapse)
-
- (LocalLogger) initialize(io)
constructor
make local logger with color.
-
- (Object) log(severity, message, progname)
output to logger with unixtime.
Constructor Details
- (LocalLogger) initialize(io)
make local logger with color
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ros/log.rb', line 27 def initialize(io) @logger = Logger.new(io) # add color escape sequence @logger.formatter = proc {|severity, datetime, progname, msg| header = '' = '' if severity == 'ERROR' or severity == 'FATAL' header = "\e[31m" = "\e[0m" elsif severity == 'WARN' header = "\e[33m" = "\e[0m" end header + "[#{severity}] #{msg}" + + "\n" } end |
Instance Method Details
- (Object) log(severity, message, progname)
output to logger with unixtime
49 50 51 |
# File 'lib/ros/log.rb', line 49 def log(severity, , progname) return @logger.log(severity, "[Walltime: #{::Time.now.to_f}] " + , progname) end |