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.2.2"
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:



46
47
48
# File 'lib/yell.rb', line 46

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

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

Shortcut to Yell::Repository[]=

Returns:



53
54
55
# File 'lib/yell.rb', line 53

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

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



90
91
92
93
94
95
96
# File 'lib/yell.rb', line 90

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



106
107
108
109
110
111
# File 'lib/yell.rb', line 106

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



99
100
101
102
103
# File 'lib/yell.rb', line 99

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

.envObject



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/yell.rb', line 77

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:



60
61
62
# File 'lib/yell.rb', line 60

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:



39
40
41
# File 'lib/yell.rb', line 39

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

.load!(file) ⇒ Yell::Logger

Loads a config from a YAML file

Returns:



67
68
69
# File 'lib/yell.rb', line 67

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:



32
33
34
# File 'lib/yell.rb', line 32

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

.register(name, klass) ⇒ Object

Shortcut to Yell::Adapters.register



72
73
74
# File 'lib/yell.rb', line 72

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