Module: Yell

Defined in:
lib/yell.rb,
lib/yell/event.rb,
lib/yell/level.rb,
lib/yell/logger.rb,
lib/yell/version.rb,
lib/yell/adapters.rb,
lib/yell/loggable.rb,
lib/yell/silencer.rb,
lib/yell/formatter.rb,
lib/yell/repository.rb,
lib/yell/adapters/io.rb,
lib/yell/helpers/base.rb,
lib/yell/adapters/base.rb,
lib/yell/adapters/file.rb,
lib/yell/configuration.rb,
lib/yell/helpers/level.rb,
lib/yell/helpers/tracer.rb,
lib/yell/helpers/adapter.rb,
lib/yell/adapters/streams.rb,
lib/yell/helpers/silencer.rb,
lib/yell/adapters/datefile.rb,
lib/yell/helpers/formatter.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Adapters, Helpers, Loggable Classes: AdapterNotFound, Configuration, Event, Formatter, Level, Logger, LoggerNotFound, Repository, Silencer

Constant Summary collapse

Severities =

Holds all Yell severities

['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'UNKNOWN'].freeze
VERSION =
"2.0.5"
NoFormat =

No format on the log message

Examples:

logger = Yell.new STDOUT, :format => false
logger.info "Hello World!"
#=> "Hello World!"
"%m"
DefaultFormat =

Default Format

Examples:

logger = Yell.new STDOUT, :format => Yell::DefaultFormat
logger.info "Hello World!"
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 : Hello World!"
#    ^                         ^       ^       ^
#    ISO8601 Timestamp         Level   Pid     Message
"%d [%5L] %p : %m"
BasicFormat =

Basic Format

Examples:

logger = Yell.new STDOUT, :format => Yell::BasicFormat
logger.info "Hello World!"
#=> "I, 2012-02-29T09:30:00+01:00 : Hello World!"
#    ^  ^                          ^
#    ^  ISO8601 Timestamp          Message
#    Level (short)
"%l, %d : %m"
ExtendedFormat =

Extended Format

Examples:

logger = Yell.new STDOUT, :format => Yell::ExtendedFormat
logger.info "Hello World!"
#=> "2012-02-29T09:30:00+01:00 [ INFO] 65784 localhost : Hello World!"
#    ^                          ^      ^     ^           ^
#    ISO8601 Timestamp          Level  Pid   Hostname    Message
"%d [%5L] %p %h : %m"

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Yell::Logger

Shortcut to Yell::Repository[]

Returns:



49
50
51
# File 'lib/yell.rb', line 49

def []( name )
  Yell::Repository[name]
end

.[]=(name, logger) ⇒ Yell::Logger

Shortcut to Yell::Repository[]=

Returns:



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

def []=( name, logger )
  Yell::Repository[name] = logger
end

.__deprecate__(version, message, options = {}) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/yell.rb', line 93

def __deprecate__( version, message, options = {} ) #:nodoc:
  messages = ["Deprecation Warning (since v#{version}): #{message}" ]
  messages << "  before: #{options[:before]}" if options[:before]
  messages << "  after:  #{options[:after]}" if options[:after]

  __warn__(*messages)
end

.__fetch__(hash, *args) ⇒ Object



109
110
111
112
113
114
# File 'lib/yell.rb', line 109

def __fetch__( hash, *args )
  options = args.last.is_a?(Hash) ? args.pop : {}
  value = args.map { |key| hash.fetch(key.to_sym, hash[key.to_s]) }.compact.first

  value.nil? ? options[:default] : value
end

.__warn__(*messages) ⇒ Object



102
103
104
105
106
# File 'lib/yell.rb', line 102

def __warn__( *messages ) #:nodoc:
  $stderr.puts "[Yell] " + messages.join("\n")
rescue Exception => e
  # do nothing
end

.envObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/yell.rb', line 80

def env
  return ENV['YELL_ENV']  if ENV.key? 'YELL_ENV'
  return ENV['RACK_ENV']  if ENV.key? 'RACK_ENV'
  return ENV['RAILS_ENV'] if ENV.key? 'RAILS_ENV'

  if defined?(Rails)
    Rails.env
  else
    'development'
  end
end

.format(pattern = nil, date_pattern = nil, &block) ⇒ Yell::Formatter

Shortcut to Yell::Fomatter.new

Returns:



63
64
65
# File 'lib/yell.rb', line 63

def format( pattern = nil, date_pattern = nil, &block )
  Yell::Formatter.new(pattern, date_pattern, &block)
end

.level(val = nil) ⇒ Yell::Level

Shortcut to Yell::Level.new

Returns:



42
43
44
# File 'lib/yell.rb', line 42

def level( val = nil )
  Yell::Level.new(val)
end

.load!(file) ⇒ Yell::Logger

Loads a config from a YAML file

Returns:



70
71
72
# File 'lib/yell.rb', line 70

def load!( file )
  Yell.new Yell::Configuration.load!(file)
end

.new(*args, &block) ⇒ Yell::Logger

Creates a new logger instance.

Refer to #Yell::Loggger for usage.

Returns:



35
36
37
# File 'lib/yell.rb', line 35

def new( *args, &block )
  Yell::Logger.new(*args, &block)
end

.register(name, klass) ⇒ Object

Shortcut to Yell::Adapters.register



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

def register( name, klass )
  Yell::Adapters.register(name, klass)
end