sgeorgi-logging 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +262 -0
- data/README.rdoc +115 -0
- data/Rakefile +32 -0
- data/data/bad_logging_1.rb +13 -0
- data/data/bad_logging_2.rb +21 -0
- data/data/logging.rb +42 -0
- data/data/logging.yaml +63 -0
- data/data/simple_logging.rb +13 -0
- data/examples/appenders.rb +47 -0
- data/examples/classes.rb +41 -0
- data/examples/consolidation.rb +83 -0
- data/examples/fork.rb +37 -0
- data/examples/formatting.rb +51 -0
- data/examples/hierarchies.rb +73 -0
- data/examples/layouts.rb +48 -0
- data/examples/loggers.rb +29 -0
- data/examples/names.rb +43 -0
- data/examples/simple.rb +17 -0
- data/lib/logging.rb +528 -0
- data/lib/logging/appender.rb +260 -0
- data/lib/logging/appenders.rb +137 -0
- data/lib/logging/appenders/buffering.rb +178 -0
- data/lib/logging/appenders/console.rb +60 -0
- data/lib/logging/appenders/email.rb +75 -0
- data/lib/logging/appenders/file.rb +75 -0
- data/lib/logging/appenders/growl.rb +197 -0
- data/lib/logging/appenders/io.rb +69 -0
- data/lib/logging/appenders/rolling_file.rb +327 -0
- data/lib/logging/appenders/string_io.rb +68 -0
- data/lib/logging/appenders/syslog.rb +210 -0
- data/lib/logging/config/configurator.rb +188 -0
- data/lib/logging/config/yaml_configurator.rb +191 -0
- data/lib/logging/layout.rb +117 -0
- data/lib/logging/layouts.rb +47 -0
- data/lib/logging/layouts/basic.rb +32 -0
- data/lib/logging/layouts/parseable.rb +211 -0
- data/lib/logging/layouts/pattern.rb +311 -0
- data/lib/logging/log_event.rb +45 -0
- data/lib/logging/logger.rb +504 -0
- data/lib/logging/repository.rb +232 -0
- data/lib/logging/root_logger.rb +61 -0
- data/lib/logging/stats.rb +278 -0
- data/lib/logging/utils.rb +201 -0
- data/lib/spec/logging_helper.rb +34 -0
- data/test/appenders/test_buffered_io.rb +176 -0
- data/test/appenders/test_console.rb +66 -0
- data/test/appenders/test_email.rb +170 -0
- data/test/appenders/test_file.rb +95 -0
- data/test/appenders/test_growl.rb +127 -0
- data/test/appenders/test_io.rb +129 -0
- data/test/appenders/test_rolling_file.rb +209 -0
- data/test/appenders/test_syslog.rb +194 -0
- data/test/benchmark.rb +86 -0
- data/test/config/test_configurator.rb +70 -0
- data/test/config/test_yaml_configurator.rb +40 -0
- data/test/layouts/test_basic.rb +42 -0
- data/test/layouts/test_json.rb +112 -0
- data/test/layouts/test_pattern.rb +198 -0
- data/test/layouts/test_yaml.rb +121 -0
- data/test/setup.rb +43 -0
- data/test/test_appender.rb +152 -0
- data/test/test_consolidate.rb +46 -0
- data/test/test_layout.rb +110 -0
- data/test/test_log_event.rb +80 -0
- data/test/test_logger.rb +699 -0
- data/test/test_logging.rb +267 -0
- data/test/test_repository.rb +158 -0
- data/test/test_root_logger.rb +81 -0
- data/test/test_stats.rb +274 -0
- data/test/test_utils.rb +116 -0
- data/version.txt +1 -0
- metadata +227 -0
data/History.txt
ADDED
@@ -0,0 +1,262 @@
|
|
1
|
+
== 1.4.2 / 2010-04-18
|
2
|
+
|
3
|
+
Bug Fixes
|
4
|
+
- missing require for fileutils
|
5
|
+
|
6
|
+
== 1.4.1 / 2010-03-23
|
7
|
+
|
8
|
+
Bug Fixes
|
9
|
+
- flock(LOCK_UN) was causing errors on windows [issue 4]
|
10
|
+
|
11
|
+
== 1.4.0 / 2010-03-16
|
12
|
+
|
13
|
+
Minor Enhancements
|
14
|
+
- Compatibility with the Rack::CommonLogger
|
15
|
+
|
16
|
+
== 1.3.0 / 2009-12-18
|
17
|
+
|
18
|
+
Minor Enhancements
|
19
|
+
- Using copy/truncate semantics for a faster RollingFile appender
|
20
|
+
- Global reopen method for using Logging in forked environments
|
21
|
+
- RollingFile appender can use date stamps instead of numbers
|
22
|
+
|
23
|
+
== 1.2.3 / 2009-12-01
|
24
|
+
|
25
|
+
1 bug fix
|
26
|
+
- Using a reentrant mutex to avoid deadlock in some Rails applications
|
27
|
+
|
28
|
+
== 1.2.2 / 2009-08-18
|
29
|
+
|
30
|
+
1 minor enhancement
|
31
|
+
- Created a reset method for the logging framework
|
32
|
+
|
33
|
+
== 1.2.1 / 2009-08-14
|
34
|
+
|
35
|
+
1 bug fix
|
36
|
+
- Using a bug-fix version of little-plugger
|
37
|
+
|
38
|
+
== 1.2.0 / 2009-08-14
|
39
|
+
|
40
|
+
2 minor enhancements
|
41
|
+
- Added a gem based plugin system
|
42
|
+
- LogEvent is now a struct (slightly faster)
|
43
|
+
|
44
|
+
== 1.1.4 / 2009-05-28
|
45
|
+
|
46
|
+
1 minor enhancement
|
47
|
+
- Added a Logging.shutdown method to close out all appenders
|
48
|
+
|
49
|
+
== 1.1.3 / 2009-05-13
|
50
|
+
|
51
|
+
1 bug fix
|
52
|
+
- Fixing an alias bug on the JRuby platform
|
53
|
+
|
54
|
+
== 1.1.2 / 2009-05-05
|
55
|
+
|
56
|
+
1 minor enhancement
|
57
|
+
- Added two new require methods to Kernel
|
58
|
+
|
59
|
+
== 1.1.1 / 2009-04-30
|
60
|
+
|
61
|
+
1 minor enhancement
|
62
|
+
- Added a 'filename' method to the file appenders
|
63
|
+
|
64
|
+
== 1.1.0 / 2009-04-21
|
65
|
+
|
66
|
+
3 minor enhancements
|
67
|
+
- Added a "global" logger method
|
68
|
+
- Loggers can be consolidated on a per-namespace basis
|
69
|
+
- Added a precision to the logger name specifier in the pattern layout
|
70
|
+
[addresses http://github.com/TwP/logging/issues#issue/1]
|
71
|
+
|
72
|
+
== 1.0.0 / 2009-04-17
|
73
|
+
|
74
|
+
2 major enhancements
|
75
|
+
- Refactored access to the appenders
|
76
|
+
- Created a much cleaner way to initialize the logging framework
|
77
|
+
3 minor enhancements
|
78
|
+
- Added a YAML layout option
|
79
|
+
- Added a JSON layout option
|
80
|
+
- Cration of an "examples" directory
|
81
|
+
1 bug fix
|
82
|
+
- Logging initialization happens implicitly when a logger, layout, or
|
83
|
+
appender is created
|
84
|
+
|
85
|
+
== 0.9.8 / 2009-04-11
|
86
|
+
|
87
|
+
2 minor enhancements
|
88
|
+
- Adding a to_s method to the StringIo appender's StringIO object
|
89
|
+
- Added a Spec::LoggingHelper class that will capture log messages
|
90
|
+
when using rspec style testing
|
91
|
+
|
92
|
+
== 0.9.7 / 2009-03-17
|
93
|
+
|
94
|
+
1 minor enhancement
|
95
|
+
- Added a StringIO appender
|
96
|
+
1 bug fix
|
97
|
+
- Handling objects that cannot be dumped via YAML [Tim Galeckas]
|
98
|
+
|
99
|
+
== 0.9.6 / 2009-02-02
|
100
|
+
|
101
|
+
2 minor enhancements
|
102
|
+
- Ruby 1.9.1 compatability
|
103
|
+
- JRuby 1.1.5 compatability
|
104
|
+
|
105
|
+
== 0.9.5 / 2009-01-25
|
106
|
+
|
107
|
+
2 minor enhancements
|
108
|
+
- The pattern layout can output the current thread name
|
109
|
+
if set using Thread.current[:name] [valodzka]
|
110
|
+
- Added buffered logging to all IO based loggers
|
111
|
+
(console, file, rolling file)
|
112
|
+
1 bug fix
|
113
|
+
- Uncaught TimeoutError in the e-mail appender
|
114
|
+
|
115
|
+
== 0.9.4 / 2008-10-04
|
116
|
+
|
117
|
+
2 minor enhancements
|
118
|
+
- Flag to suppress exception backtraces from being logged
|
119
|
+
- Cleaning up color codes on Growl output
|
120
|
+
4 bug fixes
|
121
|
+
- Child loggers were not being found in some cases
|
122
|
+
- RollingFileAppender fails to reopen the log file if
|
123
|
+
the log file is deleted.
|
124
|
+
- Fixed a copy/paste error in the YAML configurator
|
125
|
+
- Bug in the configurator where a nil object was being used
|
126
|
+
|
127
|
+
== 0.9.3 / 2008-09-12
|
128
|
+
|
129
|
+
2 minor enhancement
|
130
|
+
- Added a class for tracking basic statistics
|
131
|
+
- Will use the 'fastthread' gem if availble
|
132
|
+
|
133
|
+
== 0.9.2 / 2008-09-03
|
134
|
+
|
135
|
+
2 bug fixes
|
136
|
+
- Properly generates logger names for anonymous classes and
|
137
|
+
modules and meta-classes
|
138
|
+
- Fixed the rescue clause when 'turn' cannot be required
|
139
|
+
|
140
|
+
== 0.9.1 / 2008-08-14
|
141
|
+
|
142
|
+
1 minor enhancement
|
143
|
+
- added a method to show the logging configuration
|
144
|
+
2 bug fixes
|
145
|
+
- checking for sync method on the IO streams before calling
|
146
|
+
- fixed the internal logging levels
|
147
|
+
|
148
|
+
== 0.9.0 / 2008-07-16
|
149
|
+
|
150
|
+
2 minor enhancement
|
151
|
+
- Exceptions from appenders are captured and logged
|
152
|
+
- Internal logger for the Logging framework (disabled by default)
|
153
|
+
- Added a DSL configuration format (more readable than YAML)
|
154
|
+
1 bug fix
|
155
|
+
- Modules could not have their own logger instance
|
156
|
+
|
157
|
+
== 0.8.0 / 2008-07-02
|
158
|
+
|
159
|
+
1 minor enhancement
|
160
|
+
- Setting the log level of a parent will cause this level to
|
161
|
+
be propagated to the children
|
162
|
+
1 bug fix
|
163
|
+
- Fixed error with the e-mail appender and missing hostname
|
164
|
+
|
165
|
+
== 0.7.1 / 2008-02-25
|
166
|
+
|
167
|
+
1 minor enhancement
|
168
|
+
- Removed dependency on the Lockfile gem (brought the ruby
|
169
|
+
file into the logging/stelan directory)
|
170
|
+
1 bug fix
|
171
|
+
- Fixed bug with age based rolling: was not multi-process safe
|
172
|
+
|
173
|
+
== 0.7.0 / 2008-02-12
|
174
|
+
|
175
|
+
1 major enhancement
|
176
|
+
- Rails compatibility
|
177
|
+
* renamed Logger#add method to Logger#add_appenders
|
178
|
+
* renamed Logger#remove method to Logger#remove_appenders
|
179
|
+
* renamed Logger#clear method to Logger#clear_appenders
|
180
|
+
* added a new Logger#add method that conforms to the calling
|
181
|
+
semantics of the Ruby stdlib Logger
|
182
|
+
|
183
|
+
2 minor enhancements
|
184
|
+
- Speed improvements and test coverage
|
185
|
+
- Created a top-level Logging.init method that is used to
|
186
|
+
define the default logging levels
|
187
|
+
|
188
|
+
1 bug fix
|
189
|
+
- Tweaked windows detection code
|
190
|
+
|
191
|
+
== 0.6.3 / 2008-02-08
|
192
|
+
|
193
|
+
2 minor enhancements
|
194
|
+
- YAML configuration now supports multiple keys -- i.e. development
|
195
|
+
or production or whatever
|
196
|
+
- Reorganized a lot of files so that requiring files is cleaner and
|
197
|
+
more deterministic
|
198
|
+
|
199
|
+
== 0.6.2 / 2008-02-06
|
200
|
+
|
201
|
+
2 bug fixes
|
202
|
+
- An extra e-mail was being pushed out when the e-mail
|
203
|
+
appender was closed
|
204
|
+
- Created an at_exit handler to close all appenders
|
205
|
+
|
206
|
+
== 0.6.1 / 2008-01-01
|
207
|
+
|
208
|
+
1 bug fix
|
209
|
+
- Fixed include order to avoid double loading when testing
|
210
|
+
|
211
|
+
== 0.6.0 / 2007-12-26
|
212
|
+
|
213
|
+
* Using the new 'getopt' method for handling option hashes
|
214
|
+
* Rolling file appender is safe for multiple processes
|
215
|
+
* Added an e-mail appender from Jeremy Hinegardner
|
216
|
+
* Updated tests for the appenders
|
217
|
+
|
218
|
+
== 0.5.3 / 2007-12-08
|
219
|
+
|
220
|
+
* Fixed the quoting for messages sent to the growl appender
|
221
|
+
|
222
|
+
== 0.5.2 / 2007-11-28
|
223
|
+
|
224
|
+
* Updated the library to work with Ruby 1.9
|
225
|
+
* Fixed coalescing with the growl appender
|
226
|
+
|
227
|
+
== 0.5.1 / 2007-11-18
|
228
|
+
|
229
|
+
* Fixed a bug on Windows when attempting to load the syslog library
|
230
|
+
|
231
|
+
== 0.5.0 / 2007-11-18
|
232
|
+
|
233
|
+
* Added the ability to log via the syslog daemon
|
234
|
+
* Can send messages to the Growl notification system on Mac OS X
|
235
|
+
* The Growl appender can coalesce messages of the same title/priority
|
236
|
+
|
237
|
+
== 0.4.0 / 2007-03-21
|
238
|
+
|
239
|
+
* Added a microsecond flag to the Pattern layout
|
240
|
+
* All appenders write immediately upon receipt of a logging event
|
241
|
+
* Added a basic logging method that returns a logger object configured in
|
242
|
+
the same manner as the standard Ruby logger
|
243
|
+
* Fixed a bug caused by nil log messages
|
244
|
+
|
245
|
+
== 0.3.1 / 2007-02-08
|
246
|
+
|
247
|
+
* Bugfix Release
|
248
|
+
|
249
|
+
== 0.3.0 / 2007-02-01
|
250
|
+
|
251
|
+
* Remove the ability to log multiple objects from a single log method call
|
252
|
+
|
253
|
+
== 0.2.0 / 2007-01-29
|
254
|
+
|
255
|
+
* The "once every four years" release
|
256
|
+
* Storage and retrieval of appenders by name
|
257
|
+
* YAML configuration support
|
258
|
+
* Rolling file appender
|
259
|
+
|
260
|
+
== 0.1.0 / 2007-01-12
|
261
|
+
|
262
|
+
* Birthday!
|
data/README.rdoc
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
Logging
|
2
|
+
by Tim Pease
|
3
|
+
|
4
|
+
* {Homepage}[http://logging.rubyforge.org/]
|
5
|
+
* {Rubyforge Project}[http://rubyforge.org/projects/logging]
|
6
|
+
* email tim dot pease at gmail dot com
|
7
|
+
|
8
|
+
== DESCRIPTION
|
9
|
+
|
10
|
+
Logging is a flexible logging library for use in Ruby programs based on the
|
11
|
+
design of Java's log4j library. It features a hierarchical logging system,
|
12
|
+
custom level names, multiple output destinations per log event, custom
|
13
|
+
formatting, and more.
|
14
|
+
|
15
|
+
== INSTALL
|
16
|
+
|
17
|
+
sudo gem install logging
|
18
|
+
|
19
|
+
== EXAMPLE
|
20
|
+
|
21
|
+
This example configures a logger to output messages in a format similar to the
|
22
|
+
core ruby Logger class. Only log messages that are warnings or higher will be
|
23
|
+
logged.
|
24
|
+
|
25
|
+
require 'logging'
|
26
|
+
|
27
|
+
logger = Logging.logger(STDOUT)
|
28
|
+
logger.level = :warn
|
29
|
+
|
30
|
+
logger.debug "this debug message will not be output by the logger"
|
31
|
+
logger.warn "this is your last warning"
|
32
|
+
|
33
|
+
In this example, a single logger is crated that will append to STDOUT and to a
|
34
|
+
file. Only log messages that are informational or higher will be logged.
|
35
|
+
|
36
|
+
require 'logging'
|
37
|
+
|
38
|
+
logger = Logging.logger['example_logger']
|
39
|
+
logger.add_appenders(
|
40
|
+
Logging.appenders.stdout,
|
41
|
+
Logging.appenders.file('example.log')
|
42
|
+
)
|
43
|
+
logger.level = :info
|
44
|
+
|
45
|
+
logger.debug "this debug message will not be output by the logger"
|
46
|
+
logger.info "just some friendly advice"
|
47
|
+
|
48
|
+
The Logging library was created to allow each class in a program to have its
|
49
|
+
own configurable logger. The logging level for a particular class can be
|
50
|
+
changed independently of all other loggers in the system. This example shows
|
51
|
+
the recommended way of accomplishing this.
|
52
|
+
|
53
|
+
require 'logging'
|
54
|
+
|
55
|
+
Logging.logger['FirstClass'].level = :warn
|
56
|
+
Logging.logger['SecondClass'].level = :debug
|
57
|
+
|
58
|
+
class FirstClass
|
59
|
+
def initialize
|
60
|
+
@log = Logging.logger[self]
|
61
|
+
end
|
62
|
+
|
63
|
+
def some_method
|
64
|
+
@log.debug "some method was called on #{self.inspect}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class SecondClass
|
69
|
+
def initialize
|
70
|
+
@log = Logging.logger[self]
|
71
|
+
end
|
72
|
+
|
73
|
+
def another_method
|
74
|
+
@log.debug "another method was called on #{self.inspect}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
There are many more examples in the "examples" folder of the logging
|
79
|
+
package. The recommended reading order is the following:
|
80
|
+
|
81
|
+
simple.rb
|
82
|
+
loggers.rb
|
83
|
+
classes.rb
|
84
|
+
hierarchies.rb
|
85
|
+
names.rb
|
86
|
+
appenders.rb
|
87
|
+
layouts.rb
|
88
|
+
formatting.rb
|
89
|
+
consolidation.rb
|
90
|
+
|
91
|
+
== NOTES
|
92
|
+
|
93
|
+
Although Logging is intended to supersede Log4r, it is not a one-to-one
|
94
|
+
replacement for the Log4r library. Most notably is the difference in namespaces
|
95
|
+
-- Logging vs. Log4r. Other differences include renaming Log4r::Outputter to
|
96
|
+
Logging::Appender and renaming Log4r::Formatter to Logging::Layout. These
|
97
|
+
changes were meant to bring the Logging class names more in line with the Log4j
|
98
|
+
class names.
|
99
|
+
|
100
|
+
== REQUIREMENTS
|
101
|
+
|
102
|
+
Logging requires the "lockfile" gem to run and the "flexmock" gem to run the
|
103
|
+
tests"
|
104
|
+
|
105
|
+
== DEVELOPMENT REQUIREMENTS
|
106
|
+
|
107
|
+
The Logging source code relies on the Mr Bones project for default rake tasks.
|
108
|
+
You will need to install the Mr Bones gem if you want to build or test the
|
109
|
+
logging gem.
|
110
|
+
|
111
|
+
gem install bones
|
112
|
+
|
113
|
+
== LICENSE
|
114
|
+
|
115
|
+
Ruby
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
rescue LoadError
|
5
|
+
abort '### please install the "bones" gem ###'
|
6
|
+
end
|
7
|
+
|
8
|
+
task :default => 'test:run'
|
9
|
+
task 'gem:release' => 'test:run'
|
10
|
+
|
11
|
+
Bones {
|
12
|
+
name 'logging'
|
13
|
+
summary 'A flexible and extendable logging library for Ruby'
|
14
|
+
authors 'Tim Pease'
|
15
|
+
email 'tim.pease@gmail.com'
|
16
|
+
url 'http://rubygems.org/gems/logging'
|
17
|
+
readme_file 'README.rdoc'
|
18
|
+
ignore_file '.gitignore'
|
19
|
+
|
20
|
+
rdoc.exclude << '^data'
|
21
|
+
rdoc.include << '^examples/.*\.rb'
|
22
|
+
#rdoc.dir = 'doc/rdoc'
|
23
|
+
|
24
|
+
use_gmail
|
25
|
+
|
26
|
+
depend_on 'little-plugger'
|
27
|
+
|
28
|
+
depend_on 'flexmock', :development => true
|
29
|
+
depend_on 'bones-git', :development => true
|
30
|
+
depend_on 'bones-extras', :development => true
|
31
|
+
}
|
32
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Logging.configure {
|
3
|
+
|
4
|
+
logger(:root) {
|
5
|
+
level :info
|
6
|
+
appenders 'logfile'
|
7
|
+
}
|
8
|
+
|
9
|
+
appender('logfile') {
|
10
|
+
type 'File'
|
11
|
+
level 'DEB'
|
12
|
+
filename 'tmp/temp.log'
|
13
|
+
truncate true
|
14
|
+
layout {
|
15
|
+
type 'BadLayout'
|
16
|
+
date_method 'to_s'
|
17
|
+
pattern '[%d] %l %c : %m\n'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
} # logging configuration
|