Class: Eye::Logger

Inherits:
Object show all
Defined in:
lib/eye/logger.rb

Direct Known Subclasses

InnerLogger

Defined Under Namespace

Modules: ObjectExt Classes: InnerLogger

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix = nil, subprefix = nil) ⇒ Logger

Returns a new instance of Logger.


58
59
60
61
# File 'lib/eye/logger.rb', line 58

def initialize(prefix = nil, subprefix = nil)
  @prefix = prefix
  @subprefix = subprefix
end

Class Attribute Details

.argsObject (readonly)

Returns the value of attribute args


65
66
67
# File 'lib/eye/logger.rb', line 65

def args
  @args
end

.devObject (readonly)

Returns the value of attribute dev


65
66
67
# File 'lib/eye/logger.rb', line 65

def dev
  @dev
end

.log_levelObject

Returns the value of attribute log_level


65
66
67
# File 'lib/eye/logger.rb', line 65

def log_level
  @log_level
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix


5
6
7
# File 'lib/eye/logger.rb', line 5

def prefix
  @prefix
end

#subprefixObject

Returns the value of attribute subprefix


5
6
7
# File 'lib/eye/logger.rb', line 5

def subprefix
  @subprefix
end

Class Method Details

.inner_loggerObject


99
100
101
# File 'lib/eye/logger.rb', line 99

def inner_logger
  @inner_logger ||= InnerLogger.new(nil)
end

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/eye/logger.rb', line 67

def link_logger(dev, *args)
  old_dev = @dev
  @dev = @dev_fd = dev
  @args = args

  if dev.nil?
    @inner_logger = InnerLogger.new(nil)
  elsif dev.is_a?(String)
    @dev_fd = STDOUT if @dev.to_s.casecmp('stdout') == 0
    @dev_fd = STDERR if @dev.to_s.casecmp('stderr') == 0
    @inner_logger = InnerLogger.new(@dev_fd, *args)
  else
    @inner_logger = dev
  end

  @inner_logger.level = log_level || Logger::INFO

rescue Exception
  @inner_logger = nil
  @dev = old_dev
  raise
end

.reopenObject


90
91
92
# File 'lib/eye/logger.rb', line 90

def reopen
  link_logger(dev, *args)
end