Class: Nanite::Log

Inherits:
Object show all
Defined in:
lib/nanite/log.rb,
lib/nanite/log/formatter.rb

Defined Under Namespace

Classes: Formatter

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.fileObject

:nodoc



11
12
13
# File 'lib/nanite/log.rb', line 11

def file
  @file
end

.levelObject

:nodoc



11
12
13
# File 'lib/nanite/log.rb', line 11

def level
  @level
end

.loggerObject

:nodoc



11
12
13
# File 'lib/nanite/log.rb', line 11

def logger
  @logger
end

Class Method Details

.init(identity = nil, path = false) ⇒ Object

Use Nanite::Logger.init when you want to set up the logger manually. If this method is called with no arguments, it will log to STDOUT at the :info level. It also configures the Logger instance it creates to use the custom Nanite::Log::Formatter class.



16
17
18
19
20
21
22
23
24
25
# File 'lib/nanite/log.rb', line 16

def init(identity = nil, path = false)
  if path
    @file = File.join(path, "nanite.#{identity}.log")
  else
    @file = STDOUT
  end
  @logger = Logger.new(file)
  @logger.formatter = Nanite::Log::Formatter.new
  level = @log_level = :info
end

.method_missing(method_symbol, *args) ⇒ Object

Passes any other method calls on directly to the underlying Logger object created with init. If this method gets hit before a call to Nanite::Logger.init has been made, it will call Nanite::Logger.init() with no arguments.



54
55
56
57
58
59
60
61
# File 'lib/nanite/log.rb', line 54

def method_missing(method_symbol, *args)
  init unless @logger
  if args.length > 0
    @logger.send(method_symbol, *args)
  else
    @logger.send(method_symbol)
  end
end