TwP-logging 0.9.7

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 (54) hide show
  1. data/History.txt +169 -0
  2. data/README.rdoc +102 -0
  3. data/Rakefile +42 -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/lib/logging.rb +408 -0
  10. data/lib/logging/appender.rb +303 -0
  11. data/lib/logging/appenders/buffering.rb +167 -0
  12. data/lib/logging/appenders/console.rb +62 -0
  13. data/lib/logging/appenders/email.rb +75 -0
  14. data/lib/logging/appenders/file.rb +54 -0
  15. data/lib/logging/appenders/growl.rb +197 -0
  16. data/lib/logging/appenders/io.rb +69 -0
  17. data/lib/logging/appenders/rolling_file.rb +291 -0
  18. data/lib/logging/appenders/syslog.rb +201 -0
  19. data/lib/logging/config/configurator.rb +190 -0
  20. data/lib/logging/config/yaml_configurator.rb +195 -0
  21. data/lib/logging/layout.rb +119 -0
  22. data/lib/logging/layouts/basic.rb +34 -0
  23. data/lib/logging/layouts/pattern.rb +296 -0
  24. data/lib/logging/log_event.rb +51 -0
  25. data/lib/logging/logger.rb +490 -0
  26. data/lib/logging/repository.rb +172 -0
  27. data/lib/logging/root_logger.rb +61 -0
  28. data/lib/logging/stats.rb +278 -0
  29. data/lib/logging/utils.rb +130 -0
  30. data/logging.gemspec +41 -0
  31. data/test/appenders/test_buffered_io.rb +183 -0
  32. data/test/appenders/test_console.rb +66 -0
  33. data/test/appenders/test_email.rb +171 -0
  34. data/test/appenders/test_file.rb +93 -0
  35. data/test/appenders/test_growl.rb +128 -0
  36. data/test/appenders/test_io.rb +142 -0
  37. data/test/appenders/test_rolling_file.rb +207 -0
  38. data/test/appenders/test_syslog.rb +194 -0
  39. data/test/benchmark.rb +87 -0
  40. data/test/config/test_configurator.rb +70 -0
  41. data/test/config/test_yaml_configurator.rb +40 -0
  42. data/test/layouts/test_basic.rb +43 -0
  43. data/test/layouts/test_pattern.rb +177 -0
  44. data/test/setup.rb +74 -0
  45. data/test/test_appender.rb +166 -0
  46. data/test/test_layout.rb +110 -0
  47. data/test/test_log_event.rb +80 -0
  48. data/test/test_logger.rb +734 -0
  49. data/test/test_logging.rb +267 -0
  50. data/test/test_repository.rb +126 -0
  51. data/test/test_root_logger.rb +81 -0
  52. data/test/test_stats.rb +274 -0
  53. data/test/test_utils.rb +116 -0
  54. metadata +156 -0
data/History.txt ADDED
@@ -0,0 +1,169 @@
1
+ == 0.9.7 / 2009-02-
2
+
3
+ 1 bug fix
4
+ - Handling objects that cannot be dumped via YAML [Tim Galeckas]
5
+
6
+ == 0.9.6 / 2009-02-02
7
+
8
+ 2 minor enhancements
9
+ - Ruby 1.9.1 compatability
10
+ - JRuby 1.1.5 compatability
11
+
12
+ == 0.9.5 / 2009-01-25
13
+
14
+ 2 minor enhancements
15
+ - The pattern layout can output the current thread name
16
+ if set using Thread.current[:name] [valodzka]
17
+ - Added buffered logging to all IO based loggers
18
+ (console, file, rolling file)
19
+ 1 bug fix
20
+ - Uncaught TimeoutError in the e-mail appender
21
+
22
+ == 0.9.4 / 2008-10-04
23
+
24
+ 2 minor enhancements
25
+ - Flag to suppress exception backtraces from being logged
26
+ - Cleaning up color codes on Growl output
27
+ 4 bug fixes
28
+ - Child loggers were not being found in some cases
29
+ - RollingFileAppender fails to reopen the log file if
30
+ the log file is deleted.
31
+ - Fixed a copy/paste error in the YAML configurator
32
+ - Bug in the configurator where a nil object was being used
33
+
34
+ == 0.9.3 / 2008-09-12
35
+
36
+ 2 minor enhancement
37
+ - Added a class for tracking basic statistics
38
+ - Will use the 'fastthread' gem if availble
39
+
40
+ == 0.9.2 / 2008-09-03
41
+
42
+ 2 bug fixes
43
+ - Properly generates logger names for anonymous classes and
44
+ modules and meta-classes
45
+ - Fixed the rescue clause when 'turn' cannot be required
46
+
47
+ == 0.9.1 / 2008-08-14
48
+
49
+ 1 minor enhancement
50
+ - added a method to show the logging configuration
51
+ 2 bug fixes
52
+ - checking for sync method on the IO streams before calling
53
+ - fixed the internal logging levels
54
+
55
+ == 0.9.0 / 2008-07-16
56
+
57
+ 2 minor enhancement
58
+ - Exceptions from appenders are captured and logged
59
+ - Internal logger for the Logging framework (disabled by default)
60
+ - Added a DSL configuration format (more readable than YAML)
61
+ 1 bug fix
62
+ - Modules could not have their own logger instance
63
+
64
+ == 0.8.0 / 2008-07-02
65
+
66
+ 1 minor enhancement
67
+ - Setting the log level of a parent will cause this level to
68
+ be propagated to the children
69
+ 1 bug fix
70
+ - Fixed error with the e-mail appender and missing hostname
71
+
72
+ == 0.7.1 / 2008-02-25
73
+
74
+ 1 minor enhancement
75
+ - Removed dependency on the Lockfile gem (brought the ruby
76
+ file into the logging/stelan directory)
77
+ 1 bug fix
78
+ - Fixed bug with age based rolling: was not multi-process safe
79
+
80
+ == 0.7.0 / 2008-02-12
81
+
82
+ 1 major enhancement
83
+ - Rails compatibility
84
+ * renamed Logger#add method to Logger#add_appenders
85
+ * renamed Logger#remove method to Logger#remove_appenders
86
+ * renamed Logger#clear method to Logger#clear_appenders
87
+ * added a new Logger#add method that conforms to the calling
88
+ semantics of the Ruby stdlib Logger
89
+
90
+ 2 minor enhancements
91
+ - Speed improvements and test coverage
92
+ - Created a top-level Logging.init method that is used to
93
+ define the default logging levels
94
+
95
+ 1 bug fix
96
+ - Tweaked windows detection code
97
+
98
+ == 0.6.3 / 2008-02-08
99
+
100
+ 2 minor enhancements
101
+ - YAML configuration now supports multiple keys -- i.e. development
102
+ or production or whatever
103
+ - Reorganized a lot of files so that requiring files is cleaner and
104
+ more deterministic
105
+
106
+ == 0.6.2 / 2008-02-06
107
+
108
+ 2 bug fixes
109
+ - An extra e-mail was being pushed out when the e-mail
110
+ appender was closed
111
+ - Created an at_exit handler to close all appenders
112
+
113
+ == 0.6.1 / 2008-01-01
114
+
115
+ 1 bug fix
116
+ - Fixed include order to avoid double loading when testing
117
+
118
+ == 0.6.0 / 2007-12-26
119
+
120
+ * Using the new 'getopt' method for handling option hashes
121
+ * Rolling file appender is safe for multiple processes
122
+ * Added an e-mail appender from Jeremy Hinegardner
123
+ * Updated tests for the appenders
124
+
125
+ == 0.5.3 / 2007-12-08
126
+
127
+ * Fixed the quoting for messages sent to the growl appender
128
+
129
+ == 0.5.2 / 2007-11-28
130
+
131
+ * Updated the library to work with Ruby 1.9
132
+ * Fixed coalescing with the growl appender
133
+
134
+ == 0.5.1 / 2007-11-18
135
+
136
+ * Fixed a bug on Windows when attempting to load the syslog library
137
+
138
+ == 0.5.0 / 2007-11-18
139
+
140
+ * Added the ability to log via the syslog daemon
141
+ * Can send messages to the Growl notification system on Mac OS X
142
+ * The Growl appender can coalesce messages of the same title/priority
143
+
144
+ == 0.4.0 / 2007-03-21
145
+
146
+ * Added a microsecond flag to the Pattern layout
147
+ * All appenders write immediately upon receipt of a logging event
148
+ * Added a basic logging method that returns a logger object configured in
149
+ the same manner as the standard Ruby logger
150
+ * Fixed a bug caused by nil log messages
151
+
152
+ == 0.3.1 / 2007-02-08
153
+
154
+ * Bugfix Release
155
+
156
+ == 0.3.0 / 2007-02-01
157
+
158
+ * Remove the ability to log multiple objects from a single log method call
159
+
160
+ == 0.2.0 / 2007-01-29
161
+
162
+ * The "once every four years" release
163
+ * Storage and retrieval of appenders by name
164
+ * YAML configuration support
165
+ * Rolling file appender
166
+
167
+ == 0.1.0 / 2007-01-12
168
+
169
+ * Birthday!
data/README.rdoc ADDED
@@ -0,0 +1,102 @@
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::Appender.stdout,
41
+ Logging::Appenders::File.new('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
+ == NOTES
79
+
80
+ Although Logging is intended to supersede Log4r, it is not a one-to-one
81
+ replacement for the Log4r library. Most notably is the difference in namespaces
82
+ -- Logging vs. Log4r. Other differences include renaming Log4r::Outputter to
83
+ Logging::Appender and renaming Log4r::Formatter to Logging::Layout. These
84
+ changes were meant to bring the Logging class names more in line with the Log4j
85
+ class names.
86
+
87
+ == REQUIREMENTS
88
+
89
+ Logging requires the "lockfile" gem to run and the "flexmock" gem to run the
90
+ tests"
91
+
92
+ == DEVELOPMENT REQUIREMENTS
93
+
94
+ The Logging source code relies on the Mr Bones project for default rake tasks.
95
+ You will need to install the Mr Bones gem if you want to build or test the
96
+ logging gem.
97
+
98
+ gem install bones
99
+
100
+ == LICENSE
101
+
102
+ Ruby
data/Rakefile ADDED
@@ -0,0 +1,42 @@
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$]
29
+ PROJ.rdoc.exclude << '^data'
30
+ #PROJ.rdoc.dir = 'doc/rdoc'
31
+ #PROJ.rdoc.remote_dir = 'rdoc'
32
+ PROJ.rdoc.dir = 'doc'
33
+ PROJ.rdoc.remote_dir = ''
34
+
35
+ PROJ.ann.email[:server] = 'smtp.gmail.com'
36
+ PROJ.ann.email[:port] = 587
37
+ PROJ.ann.email[:from] = 'Tim Pease'
38
+
39
+ depend_on 'flexmock'
40
+ depend_on 'lockfile'
41
+
42
+ # 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
data/data/logging.yaml ADDED
@@ -0,0 +1,63 @@
1
+
2
+ purpose : TestA
3
+ description: This is the 1st YAML doc
4
+ say : Hi
5
+
6
+ ---
7
+ # *** YAML2LOGGING ***
8
+ logging_config:
9
+ # define all pre config ...
10
+ pre_config:
11
+ define_levels:
12
+ - DEB
13
+ - INF
14
+ - PRT
15
+ - WRN
16
+ - ERR
17
+ - FAT
18
+ format_as : inspect
19
+ root:
20
+ level : WRN
21
+
22
+ # define all loggers ...
23
+ loggers:
24
+ - name : mylogger
25
+ level : DEB
26
+ additive : false
27
+ trace : false
28
+ appenders:
29
+ - stderr
30
+ - logfile
31
+
32
+ - name : yourlogger
33
+ level : INF
34
+ appenders:
35
+ - stderr
36
+ - logfile
37
+
38
+ # define all appenders (incl. layouts)
39
+ appenders:
40
+ - type : Stderr
41
+ name : stderr
42
+ level : DEB
43
+ layout:
44
+ type : Basic
45
+ format_as : string
46
+
47
+ - type : File
48
+ name : logfile
49
+ level : DEB
50
+ filename : 'tmp/temp.log'
51
+ truncate : true
52
+ layout:
53
+ type : Pattern
54
+ date_method : to_s
55
+ pattern : '[%d] %l %c : %m\n'
56
+
57
+ ---
58
+ purpose : TestB
59
+ description: This is the last YAML doc
60
+ say : Bye
61
+
62
+
63
+ # EOF