lib/onering/logger.rb in onering-client-0.3.4 vs lib/onering/logger.rb in onering-client-0.4.0
- old
+ new
@@ -27,14 +27,19 @@
when :fatal then sevtag = '!!'
when :error then sevtag = 'EE'
when :warn then sevtag = 'WW'
when :info then sevtag = 'II'
when :debug then sevtag = 'DD'
+ when :output then sevtag = ''
else sevtag = '??'
end
- logline = ["#{sevtag} ", (source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
+ if options[:sevtag] == false
+ logline = [(source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
+ else
+ logline = ["#{sevtag} ", (source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
+ end
if options[:destination] === STDOUT or options[:destination] === STDERR
case severity.downcase.to_sym
when :fatal, :error
logline = logline.foreground(:red)
@@ -48,14 +53,14 @@
end
options[:destination].puts(logline)
})
- self.level = options[:threshold]
+ self.level = (options[:threshold] || :info)
self.debug("onering-client v#{Onering::Client::VERSION} started")
- self.debug("Logger is initialized. Output is #{outputfn}, threshold: #{options[:threshold]} or worse", "Onering::Logger")
+ self.debug("Logger is initialized. Output is #{outputfn || 'stderr'}, threshold: #{options[:threshold]} or worse", "Onering::Logger")
end
def self.logger()
return @_logger
@@ -109,9 +114,13 @@
self.log(:debug, message, source, 2)
end
def self.debug3(message, source=nil)
self.log(:debug, message, source, 3)
+ end
+
+ def self.output(message, source=nil)
+ self.log(:output, message, source)
end
def self._get_level(severity)
case severity.to_sym
when :fatal
\ No newline at end of file