pjstadig-logging 1.1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/History.txt +219 -0
  2. data/README.rdoc +115 -0
  3. data/Rakefile +43 -0
  4. data/data/bad_logging_1.rb +13 -0
  5. data/data/bad_logging_2.rb +21 -0
  6. data/data/logging.rb +42 -0
  7. data/data/logging.yaml +63 -0
  8. data/data/simple_logging.rb +13 -0
  9. data/examples/appenders.rb +47 -0
  10. data/examples/classes.rb +41 -0
  11. data/examples/consolidation.rb +83 -0
  12. data/examples/formatting.rb +51 -0
  13. data/examples/hierarchies.rb +73 -0
  14. data/examples/layouts.rb +48 -0
  15. data/examples/loggers.rb +29 -0
  16. data/examples/names.rb +43 -0
  17. data/examples/simple.rb +17 -0
  18. data/lib/logging.rb +479 -0
  19. data/lib/logging/appender.rb +251 -0
  20. data/lib/logging/appenders.rb +120 -0
  21. data/lib/logging/appenders/buffering.rb +168 -0
  22. data/lib/logging/appenders/console.rb +60 -0
  23. data/lib/logging/appenders/email.rb +75 -0
  24. data/lib/logging/appenders/file.rb +58 -0
  25. data/lib/logging/appenders/growl.rb +197 -0
  26. data/lib/logging/appenders/io.rb +69 -0
  27. data/lib/logging/appenders/rolling_file.rb +293 -0
  28. data/lib/logging/appenders/string_io.rb +68 -0
  29. data/lib/logging/appenders/syslog.rb +194 -0
  30. data/lib/logging/config/configurator.rb +188 -0
  31. data/lib/logging/config/yaml_configurator.rb +191 -0
  32. data/lib/logging/layout.rb +117 -0
  33. data/lib/logging/layouts.rb +47 -0
  34. data/lib/logging/layouts/basic.rb +32 -0
  35. data/lib/logging/layouts/parseable.rb +211 -0
  36. data/lib/logging/layouts/pattern.rb +312 -0
  37. data/lib/logging/log_event.rb +51 -0
  38. data/lib/logging/logger.rb +503 -0
  39. data/lib/logging/repository.rb +210 -0
  40. data/lib/logging/root_logger.rb +61 -0
  41. data/lib/logging/stats.rb +278 -0
  42. data/lib/logging/utils.rb +207 -0
  43. data/lib/spec/logging_helper.rb +34 -0
  44. data/test/appenders/test_buffered_io.rb +176 -0
  45. data/test/appenders/test_console.rb +66 -0
  46. data/test/appenders/test_email.rb +170 -0
  47. data/test/appenders/test_file.rb +95 -0
  48. data/test/appenders/test_growl.rb +127 -0
  49. data/test/appenders/test_io.rb +129 -0
  50. data/test/appenders/test_rolling_file.rb +200 -0
  51. data/test/appenders/test_syslog.rb +194 -0
  52. data/test/benchmark.rb +86 -0
  53. data/test/config/test_configurator.rb +70 -0
  54. data/test/config/test_yaml_configurator.rb +40 -0
  55. data/test/layouts/test_basic.rb +42 -0
  56. data/test/layouts/test_json.rb +112 -0
  57. data/test/layouts/test_pattern.rb +198 -0
  58. data/test/layouts/test_yaml.rb +121 -0
  59. data/test/setup.rb +73 -0
  60. data/test/test_appender.rb +152 -0
  61. data/test/test_consolidate.rb +46 -0
  62. data/test/test_layout.rb +110 -0
  63. data/test/test_log_event.rb +80 -0
  64. data/test/test_logger.rb +699 -0
  65. data/test/test_logging.rb +267 -0
  66. data/test/test_repository.rb +158 -0
  67. data/test/test_root_logger.rb +81 -0
  68. data/test/test_stats.rb +274 -0
  69. data/test/test_utils.rb +116 -0
  70. metadata +175 -0
data/History.txt ADDED
@@ -0,0 +1,219 @@
1
+ == 1.1.4 / 2009-05-28
2
+
3
+ 1 minor enhancement
4
+ - Added a Logging.shutdown method to close out all appenders
5
+
6
+ == 1.1.3 / 2009-05-13
7
+
8
+ 1 bug fix
9
+ - Fixing an alias bug on the JRuby platform
10
+
11
+ == 1.1.2 / 2009-05-05
12
+
13
+ 1 minor enhancement
14
+ - Added two new require methods to Kernel
15
+
16
+ == 1.1.1 / 2009-04-30
17
+
18
+ 1 minor enhancement
19
+ - Added a 'filename' method to the file appenders
20
+
21
+ == 1.1.0 / 2009-04-21
22
+
23
+ 3 minor enhancements
24
+ - Added a "global" logger method
25
+ - Loggers can be consolidated on a per-namespace basis
26
+ - Added a precision to the logger name specifier in the pattern layout
27
+ [addresses http://github.com/TwP/logging/issues#issue/1]
28
+
29
+ == 1.0.0 / 2009-04-17
30
+
31
+ 2 major enhancements
32
+ - Refactored access to the appenders
33
+ - Created a much cleaner way to initialize the logging framework
34
+ 3 minor enhancements
35
+ - Added a YAML layout option
36
+ - Added a JSON layout option
37
+ - Cration of an "examples" directory
38
+ 1 bug fix
39
+ - Logging initialization happens implicitly when a logger, layout, or
40
+ appender is created
41
+
42
+ == 0.9.8 / 2009-04-11
43
+
44
+ 2 minor enhancements
45
+ - Adding a to_s method to the StringIo appender's StringIO object
46
+ - Added a Spec::LoggingHelper class that will capture log messages
47
+ when using rspec style testing
48
+
49
+ == 0.9.7 / 2009-03-17
50
+
51
+ 1 minor enhancement
52
+ - Added a StringIO appender
53
+ 1 bug fix
54
+ - Handling objects that cannot be dumped via YAML [Tim Galeckas]
55
+
56
+ == 0.9.6 / 2009-02-02
57
+
58
+ 2 minor enhancements
59
+ - Ruby 1.9.1 compatability
60
+ - JRuby 1.1.5 compatability
61
+
62
+ == 0.9.5 / 2009-01-25
63
+
64
+ 2 minor enhancements
65
+ - The pattern layout can output the current thread name
66
+ if set using Thread.current[:name] [valodzka]
67
+ - Added buffered logging to all IO based loggers
68
+ (console, file, rolling file)
69
+ 1 bug fix
70
+ - Uncaught TimeoutError in the e-mail appender
71
+
72
+ == 0.9.4 / 2008-10-04
73
+
74
+ 2 minor enhancements
75
+ - Flag to suppress exception backtraces from being logged
76
+ - Cleaning up color codes on Growl output
77
+ 4 bug fixes
78
+ - Child loggers were not being found in some cases
79
+ - RollingFileAppender fails to reopen the log file if
80
+ the log file is deleted.
81
+ - Fixed a copy/paste error in the YAML configurator
82
+ - Bug in the configurator where a nil object was being used
83
+
84
+ == 0.9.3 / 2008-09-12
85
+
86
+ 2 minor enhancement
87
+ - Added a class for tracking basic statistics
88
+ - Will use the 'fastthread' gem if availble
89
+
90
+ == 0.9.2 / 2008-09-03
91
+
92
+ 2 bug fixes
93
+ - Properly generates logger names for anonymous classes and
94
+ modules and meta-classes
95
+ - Fixed the rescue clause when 'turn' cannot be required
96
+
97
+ == 0.9.1 / 2008-08-14
98
+
99
+ 1 minor enhancement
100
+ - added a method to show the logging configuration
101
+ 2 bug fixes
102
+ - checking for sync method on the IO streams before calling
103
+ - fixed the internal logging levels
104
+
105
+ == 0.9.0 / 2008-07-16
106
+
107
+ 2 minor enhancement
108
+ - Exceptions from appenders are captured and logged
109
+ - Internal logger for the Logging framework (disabled by default)
110
+ - Added a DSL configuration format (more readable than YAML)
111
+ 1 bug fix
112
+ - Modules could not have their own logger instance
113
+
114
+ == 0.8.0 / 2008-07-02
115
+
116
+ 1 minor enhancement
117
+ - Setting the log level of a parent will cause this level to
118
+ be propagated to the children
119
+ 1 bug fix
120
+ - Fixed error with the e-mail appender and missing hostname
121
+
122
+ == 0.7.1 / 2008-02-25
123
+
124
+ 1 minor enhancement
125
+ - Removed dependency on the Lockfile gem (brought the ruby
126
+ file into the logging/stelan directory)
127
+ 1 bug fix
128
+ - Fixed bug with age based rolling: was not multi-process safe
129
+
130
+ == 0.7.0 / 2008-02-12
131
+
132
+ 1 major enhancement
133
+ - Rails compatibility
134
+ * renamed Logger#add method to Logger#add_appenders
135
+ * renamed Logger#remove method to Logger#remove_appenders
136
+ * renamed Logger#clear method to Logger#clear_appenders
137
+ * added a new Logger#add method that conforms to the calling
138
+ semantics of the Ruby stdlib Logger
139
+
140
+ 2 minor enhancements
141
+ - Speed improvements and test coverage
142
+ - Created a top-level Logging.init method that is used to
143
+ define the default logging levels
144
+
145
+ 1 bug fix
146
+ - Tweaked windows detection code
147
+
148
+ == 0.6.3 / 2008-02-08
149
+
150
+ 2 minor enhancements
151
+ - YAML configuration now supports multiple keys -- i.e. development
152
+ or production or whatever
153
+ - Reorganized a lot of files so that requiring files is cleaner and
154
+ more deterministic
155
+
156
+ == 0.6.2 / 2008-02-06
157
+
158
+ 2 bug fixes
159
+ - An extra e-mail was being pushed out when the e-mail
160
+ appender was closed
161
+ - Created an at_exit handler to close all appenders
162
+
163
+ == 0.6.1 / 2008-01-01
164
+
165
+ 1 bug fix
166
+ - Fixed include order to avoid double loading when testing
167
+
168
+ == 0.6.0 / 2007-12-26
169
+
170
+ * Using the new 'getopt' method for handling option hashes
171
+ * Rolling file appender is safe for multiple processes
172
+ * Added an e-mail appender from Jeremy Hinegardner
173
+ * Updated tests for the appenders
174
+
175
+ == 0.5.3 / 2007-12-08
176
+
177
+ * Fixed the quoting for messages sent to the growl appender
178
+
179
+ == 0.5.2 / 2007-11-28
180
+
181
+ * Updated the library to work with Ruby 1.9
182
+ * Fixed coalescing with the growl appender
183
+
184
+ == 0.5.1 / 2007-11-18
185
+
186
+ * Fixed a bug on Windows when attempting to load the syslog library
187
+
188
+ == 0.5.0 / 2007-11-18
189
+
190
+ * Added the ability to log via the syslog daemon
191
+ * Can send messages to the Growl notification system on Mac OS X
192
+ * The Growl appender can coalesce messages of the same title/priority
193
+
194
+ == 0.4.0 / 2007-03-21
195
+
196
+ * Added a microsecond flag to the Pattern layout
197
+ * All appenders write immediately upon receipt of a logging event
198
+ * Added a basic logging method that returns a logger object configured in
199
+ the same manner as the standard Ruby logger
200
+ * Fixed a bug caused by nil log messages
201
+
202
+ == 0.3.1 / 2007-02-08
203
+
204
+ * Bugfix Release
205
+
206
+ == 0.3.0 / 2007-02-01
207
+
208
+ * Remove the ability to log multiple objects from a single log method call
209
+
210
+ == 0.2.0 / 2007-01-29
211
+
212
+ * The "once every four years" release
213
+ * Storage and retrieval of appenders by name
214
+ * YAML configuration support
215
+ * Rolling file appender
216
+
217
+ == 0.1.0 / 2007-01-12
218
+
219
+ * 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,43 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ Bones.setup
5
+ rescue LoadError
6
+ begin
7
+ load 'tasks/setup.rb'
8
+ rescue LoadError
9
+ raise RuntimeError, '### please install the "bones" gem ###'
10
+ end
11
+ end
12
+
13
+ ensure_in_path 'lib'
14
+ require 'logging'
15
+
16
+ task :default => 'test:run'
17
+
18
+ PROJ.name = 'logging'
19
+ PROJ.summary = 'A flexible and extendable logging library for Ruby'
20
+ PROJ.authors = 'Tim Pease'
21
+ PROJ.email = 'tim.pease@gmail.com'
22
+ PROJ.url = 'http://logging.rubyforge.org/'
23
+ PROJ.rubyforge.name = 'logging'
24
+ PROJ.version = Logging::VERSION
25
+ PROJ.readme_file = 'README.rdoc'
26
+ PROJ.ignore_file = '.gitignore'
27
+
28
+ PROJ.exclude << %w[^tags$ logging.gemspec]
29
+ PROJ.rdoc.exclude << '^data'
30
+ PROJ.rdoc.include << '^examples/.*\.rb'
31
+ #PROJ.rdoc.dir = 'doc/rdoc'
32
+ #PROJ.rdoc.remote_dir = 'rdoc'
33
+ PROJ.rdoc.dir = 'doc'
34
+ PROJ.rdoc.remote_dir = ''
35
+
36
+ PROJ.ann.email[:server] = 'smtp.gmail.com'
37
+ PROJ.ann.email[:port] = 587
38
+ PROJ.ann.email[:from] = 'Tim Pease'
39
+
40
+ depend_on 'flexmock'
41
+ depend_on 'lockfile'
42
+
43
+ # EOF
@@ -0,0 +1,13 @@
1
+
2
+ Logging.configure {
3
+
4
+ logger(:root) {
5
+ level :info
6
+ appenders 'bad'
7
+ }
8
+
9
+ appender('bad') {
10
+ type 'FooBar'
11
+ }
12
+
13
+ } # logging configuration
@@ -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
data/data/logging.rb ADDED
@@ -0,0 +1,42 @@
1
+
2
+ Logging.configure {
3
+
4
+ pre_config {
5
+ levels %w[DEB INF PRT WRN ERR FAT]
6
+ format_as :inspect
7
+ }
8
+
9
+ logger('A::B::C') {
10
+ level 'DEB'
11
+ additive false
12
+ trace false
13
+ appenders %w[stderr logfile]
14
+ }
15
+
16
+ logger('yourlogger') {
17
+ level 'INF'
18
+ appenders %w[stderr logfile]
19
+ }
20
+
21
+ appender('stderr') {
22
+ type 'Stderr'
23
+ level 'DEB'
24
+ layout {
25
+ type 'Basic'
26
+ format_as :string
27
+ }
28
+ }
29
+
30
+ appender('logfile') {
31
+ type 'File'
32
+ level 'DEB'
33
+ filename 'tmp/temp.log'
34
+ truncate true
35
+ layout {
36
+ type 'Pattern'
37
+ date_method 'to_s'
38
+ pattern '[%d] %l %c : %m\n'
39
+ }
40
+ }
41
+
42
+ } # logging configuration