Skip to content
This repository
Newer
Older
100644 113 lines (95 sloc) 3.478 kb
891901fd »
2011-12-16 ST: New Yell interface and refactorings
1 # encoding: utf-8
2
3 # Copyright (c) 2011-2012 Rudolf Schmidt
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
df54887a »
2012-09-04 ST: Added Yell::Repository
15
891901fd »
2011-12-16 ST: New Yell interface and refactorings
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
f1cc0ba9 »
2011-12-16 Updated default date pattern to be the ISO8601 format
23
891901fd »
2011-12-16 ST: New Yell interface and refactorings
24 module Yell #:nodoc:
df54887a »
2012-09-04 ST: Added Yell::Repository
25
26 # Holds all Yell severities
c75270db »
2012-03-14 REF: Major refactoring
27 Severities = [ 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'UNKNOWN' ]
28
8949f806 »
2012-03-20 ST: Updated features and README
29 class << self
30 # Creates a new logger instance.
31 #
32 # Refer to #Yell::Loggger for usage.
33 #
34 # @return [Yell::Logger] The logger instance
35 def new( *args, &block )
36 Yell::Logger.new( *args, &block )
37 end
38
e3f92f28 »
2012-04-02 ST: Added some more documentation
39 # Shortcut to Yell::Level.new
40 #
df54887a »
2012-09-04 ST: Added Yell::Repository
41 # @return [Yell::Level] The level instance
4551c17a »
2012-03-31 ST: Added %t (thread_id) for Yell::Formatter
42 def level( val = nil )
43 Yell::Level.new( val )
44 end
45
df54887a »
2012-09-04 ST: Added Yell::Repository
46 # Shortcut to Yell::Repository[]
47 #
48 # @return [Yell::Logger] The logger instance
49 def []( name )
50 Yell::Repository[ name ]
51 end
52
53 # Shortcut to Yell::Repository[]=
54 #
55 # @return [Yell::Logger] The logger instance
56 def []=( name, logger )
57 Yell::Repository[ name ] = logger
58 end
59
e3f92f28 »
2012-04-02 ST: Added some more documentation
60 # Shortcut to Yell::Fomatter.new
61 #
62 # @return [Yell::Formatter] A Yell::Formatter instance
4551c17a »
2012-03-31 ST: Added %t (thread_id) for Yell::Formatter
63 def format( pattern, date_pattern = nil )
64 Yell::Formatter.new( pattern, date_pattern )
65 end
66
bda53ac1 »
2012-09-03 CHORE: Updated inline doc
67 # Loads a config from a YAML file
d32b2285 »
2012-09-13 ST: Added documentaiton
68 #
69 # @return [Yell::Logger] The logger instance
5e22b1ac »
2012-05-10 ST: Added configuration from yaml file
70 def load!( file )
d32b2285 »
2012-09-13 ST: Added documentaiton
71 Yell.new Yell::Configuration.load!(file)
5e22b1ac »
2012-05-10 ST: Added configuration from yaml file
72 end
73
df54887a »
2012-09-04 ST: Added Yell::Repository
74 def env #:nodoc:
7a9422c2 »
2012-09-14 ST: Added specs for :env
75 return ENV['YELL_ENV'] if ENV.key? 'YELL_ENV'
76 return ENV['RACK_ENV'] if ENV.key? 'RACK_ENV'
77 return ENV['RAILS_ENV'] if ENV.key? 'RAILS_ENV'
78
65081d47 »
2012-09-05 FIX: Yell now reads Rails.env propverly
79 if defined?( Rails )
7a9422c2 »
2012-09-14 ST: Added specs for :env
80 Rails.env
81 else
82 'development'
65081d47 »
2012-09-05 FIX: Yell now reads Rails.env propverly
83 end
df54887a »
2012-09-04 ST: Added Yell::Repository
84 end
85
bda53ac1 »
2012-09-03 CHORE: Updated inline doc
86 def _deprecate( version, message, options = {} ) #:nodoc:
df54887a »
2012-09-04 ST: Added Yell::Repository
87 messages = ["Deprecation Warning (since v#{version}): #{message}" ]
88 messages << " before: #{options[:before]}" if options[:before]
89 messages << " after: #{options[:after]}" if options[:after]
9552792c »
2012-04-03 FIX: Issue #1 Unusual Loglevel
90
df54887a »
2012-09-04 ST: Added Yell::Repository
91 _warn( *messages )
9552792c »
2012-04-03 FIX: Issue #1 Unusual Loglevel
92 end
93
d32b2285 »
2012-09-13 ST: Added documentaiton
94 def _warn( *messages ) #:nodoc:
a82b9fa9 »
2012-09-13 ST: replace :symlink_original_filename with :symlink for datefile ada…
95 $stderr.puts "[Yell] " + messages.join( "\n" )
96 rescue
97 # do nothing
df54887a »
2012-09-04 ST: Added Yell::Repository
98 end
06e97a5f »
2012-03-07 WIP: Initial take on level
99 end
100
f1bef802 »
2011-10-23 initial import
101 end
891901fd »
2011-12-16 ST: New Yell interface and refactorings
102
feb8a90e »
2012-09-15 ST: Added Yell::Loggable module for enabling classes to easy logging
103 # classes
48e711c7 »
2012-05-11 ST: Updated configuration spec
104 require File.dirname(__FILE__) + '/yell/configuration'
df54887a »
2012-09-04 ST: Added Yell::Repository
105 require File.dirname(__FILE__) + '/yell/repository'
74e9229e »
2012-04-06 CHORE: Refactored log method definitions
106 require File.dirname(__FILE__) + '/yell/event'
107 require File.dirname(__FILE__) + '/yell/level'
108 require File.dirname(__FILE__) + '/yell/formatter'
109 require File.dirname(__FILE__) + '/yell/adapters'
110 require File.dirname(__FILE__) + '/yell/logger'
111
feb8a90e »
2012-09-15 ST: Added Yell::Loggable module for enabling classes to easy logging
112 # modules
113 require File.dirname(__FILE__) + '/yell/loggable'
114
Something went wrong with that request. Please try again.