lib/splash/loggers/daemon.rb in prometheus-splash-0.5.3 vs lib/splash/loggers/daemon.rb in prometheus-splash-0.6.0
- old
+ new
@@ -1,22 +1,32 @@
# coding: utf-8
+
+# base Splash module
module Splash
+
+ # Splash Loggers module
module Loggers
-
+ # Daemon specific logger
class Daemon < Splash::Loggers::LoggerTemplate
-
+ # contructor, open log file
+ # @return [Splash::Loggers::Daemon]
def initialize
self.level = get_config.loggers[:level]
@log_file = get_config.loggers[:daemon][:file]
@stream = File::open(@log_file, 'a')
@stream.sync = true
end
-
+ # log wrapper
+ # @param [Hash] options
+ # @option options [Symbol] :level defined in Splash::Loggers::LEVEL or Splash::Loggers::ALIAS
+ # @option options [String] :message
+ # @option options [String] :session a session number
+ # write formatted string to log file
def log(options)
pid = Process.pid.to_s
date = DateTime.now.to_s
level = (ALIAS.keys.include? options[:level])? ALIAS[options[:level]] : options[:level]
if @active_levels.include? level then
@@ -26,9 +36,10 @@
@stream.puts "[#{date}] (#{pid}) #{alt(options[:level])} : #{options[:message]}"
end
end
end
+ # close log file descriptor
def close
@stream.close
end