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.



50
51
52
53
# File 'lib/eye/logger.rb', line 50

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

Class Attribute Details

.argsObject (readonly)

Returns the value of attribute args.



56
57
58
# File 'lib/eye/logger.rb', line 56

def args
  @args
end

.devObject (readonly)

Returns the value of attribute dev.



56
57
58
# File 'lib/eye/logger.rb', line 56

def dev
  @dev
end

.log_levelObject

Returns the value of attribute log_level.



56
57
58
# File 'lib/eye/logger.rb', line 56

def log_level
  @log_level
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



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

def prefix
  @prefix
end

#subprefixObject

Returns the value of attribute subprefix.



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

def subprefix
  @subprefix
end

Class Method Details

.inner_loggerObject



84
85
86
# File 'lib/eye/logger.rb', line 84

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


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/eye/logger.rb', line 58

def link_logger(dev, *args)
  old_dev = @dev
  @dev = dev ? dev.to_s : nil
  @dev_fd = @dev
  @args = args

  @dev_fd = STDOUT if @dev.to_s.downcase == 'stdout'
  @dev_fd = STDERR if @dev.to_s.downcase == 'stderr'

  @inner_logger = InnerLogger.new(@dev_fd, *args)
  @inner_logger.level = self.log_level || Logger::INFO

rescue Errno::ENOENT, Errno::EACCES
  @dev = old_dev
  raise
end

.reopenObject



75
76
77
# File 'lib/eye/logger.rb', line 75

def reopen
  link_logger(dev, *args)
end