Sha256: 50a96973e3961b62d97dfa5d81a4e5fb3ece6c87296f84a7a7b3e0e8cb8734d0

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

# coding: utf-8
module Splash
  module Loggers


    class Daemon < Splash::Loggers::LoggerTemplate



      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


      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
          unless options[:session].empty? then
            @stream.puts "[#{date}] (#{pid}) (#{options[:session]}) #{alt(options[:level])} : #{options[:message]}"
          else
            @stream.puts "[#{date}] (#{pid}) #{alt(options[:level])} : #{options[:message]}"
          end
        end
      end

      def close
        @stream.close
      end



    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prometheus-splash-0.5.3 lib/splash/loggers/daemon.rb
prometheus-splash-0.5.2 lib/splash/loggers/daemon.rb
prometheus-splash-0.5.0 lib/splash/loggers/daemon.rb