ottobar-logging 0.9.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +158 -0
- data/README.rdoc +102 -0
- data/Rakefile +41 -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/lib/logging.rb +408 -0
- data/lib/logging/appender.rb +303 -0
- data/lib/logging/appenders/buffering.rb +167 -0
- data/lib/logging/appenders/console.rb +62 -0
- data/lib/logging/appenders/email.rb +75 -0
- data/lib/logging/appenders/file.rb +54 -0
- data/lib/logging/appenders/growl.rb +197 -0
- data/lib/logging/appenders/io.rb +69 -0
- data/lib/logging/appenders/rolling_file.rb +291 -0
- data/lib/logging/appenders/syslog.rb +201 -0
- data/lib/logging/config/configurator.rb +190 -0
- data/lib/logging/config/yaml_configurator.rb +195 -0
- data/lib/logging/layout.rb +107 -0
- data/lib/logging/layouts/basic.rb +34 -0
- data/lib/logging/layouts/pattern.rb +296 -0
- data/lib/logging/log_event.rb +49 -0
- data/lib/logging/logger.rb +491 -0
- data/lib/logging/repository.rb +172 -0
- data/lib/logging/root_logger.rb +61 -0
- data/lib/logging/stats.rb +278 -0
- data/lib/logging/utils.rb +130 -0
- data/test/appenders/test_buffered_io.rb +183 -0
- data/test/appenders/test_console.rb +66 -0
- data/test/appenders/test_email.rb +171 -0
- data/test/appenders/test_file.rb +93 -0
- data/test/appenders/test_growl.rb +128 -0
- data/test/appenders/test_io.rb +142 -0
- data/test/appenders/test_rolling_file.rb +207 -0
- data/test/appenders/test_syslog.rb +191 -0
- data/test/benchmark.rb +87 -0
- data/test/config/test_configurator.rb +70 -0
- data/test/config/test_yaml_configurator.rb +40 -0
- data/test/layouts/test_basic.rb +43 -0
- data/test/layouts/test_pattern.rb +177 -0
- data/test/setup.rb +69 -0
- data/test/test_appender.rb +166 -0
- data/test/test_layout.rb +107 -0
- data/test/test_log_event.rb +80 -0
- data/test/test_logger.rb +734 -0
- data/test/test_logging.rb +267 -0
- data/test/test_repository.rb +126 -0
- data/test/test_root_logger.rb +81 -0
- data/test/test_stats.rb +274 -0
- data/test/test_utils.rb +114 -0
- metadata +152 -0
data/History.txt
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
== 0.9.5 / 2009-01-25
|
2
|
+
|
3
|
+
2 minor enhancements
|
4
|
+
- The pattern layout can output the current thread name
|
5
|
+
if set using Thread.current[:name] [valodzka]
|
6
|
+
- Added buffered logging to all IO based loggers
|
7
|
+
(console, file, rolling file)
|
8
|
+
1 bug fix
|
9
|
+
- Uncaught TimeoutError in the e-mail appender
|
10
|
+
|
11
|
+
== 0.9.4 / 2008-10-04
|
12
|
+
|
13
|
+
2 minor enhancements
|
14
|
+
- Flag to suppress exception backtraces from being logged
|
15
|
+
- Cleaning up color codes on Growl output
|
16
|
+
4 bug fixes
|
17
|
+
- Child loggers were not being found in some cases
|
18
|
+
- RollingFileAppender fails to reopen the log file if
|
19
|
+
the log file is deleted.
|
20
|
+
- Fixed a copy/paste error in the YAML configurator
|
21
|
+
- Bug in the configurator where a nil object was being used
|
22
|
+
|
23
|
+
== 0.9.3 / 2008-09-12
|
24
|
+
|
25
|
+
2 minor enhancement
|
26
|
+
- Added a class for tracking basic statistics
|
27
|
+
- Will use the 'fastthread' gem if availble
|
28
|
+
|
29
|
+
== 0.9.2 / 2008-09-03
|
30
|
+
|
31
|
+
2 bug fixes
|
32
|
+
- Properly generates logger names for anonymous classes and
|
33
|
+
modules and meta-classes
|
34
|
+
- Fixed the rescue clause when 'turn' cannot be required
|
35
|
+
|
36
|
+
== 0.9.1 / 2008-08-14
|
37
|
+
|
38
|
+
1 minor enhancement
|
39
|
+
- added a method to show the logging configuration
|
40
|
+
2 bug fixes
|
41
|
+
- checking for sync method on the IO streams before calling
|
42
|
+
- fixed the internal logging levels
|
43
|
+
|
44
|
+
== 0.9.0 / 2008-07-16
|
45
|
+
|
46
|
+
2 minor enhancement
|
47
|
+
- Exceptions from appenders are captured and logged
|
48
|
+
- Internal logger for the Logging framework (disabled by default)
|
49
|
+
- Added a DSL configuration format (more readable than YAML)
|
50
|
+
1 bug fix
|
51
|
+
- Modules could not have their own logger instance
|
52
|
+
|
53
|
+
== 0.8.0 / 2008-07-02
|
54
|
+
|
55
|
+
1 minor enhancement
|
56
|
+
- Setting the log level of a parent will cause this level to
|
57
|
+
be propagated to the children
|
58
|
+
1 bug fix
|
59
|
+
- Fixed error with the e-mail appender and missing hostname
|
60
|
+
|
61
|
+
== 0.7.1 / 2008-02-25
|
62
|
+
|
63
|
+
1 minor enhancement
|
64
|
+
- Removed dependency on the Lockfile gem (brought the ruby
|
65
|
+
file into the logging/stelan directory)
|
66
|
+
1 bug fix
|
67
|
+
- Fixed bug with age based rolling: was not multi-process safe
|
68
|
+
|
69
|
+
== 0.7.0 / 2008-02-12
|
70
|
+
|
71
|
+
1 major enhancement
|
72
|
+
- Rails compatibility
|
73
|
+
* renamed Logger#add method to Logger#add_appenders
|
74
|
+
* renamed Logger#remove method to Logger#remove_appenders
|
75
|
+
* renamed Logger#clear method to Logger#clear_appenders
|
76
|
+
* added a new Logger#add method that conforms to the calling
|
77
|
+
semantics of the Ruby stdlib Logger
|
78
|
+
|
79
|
+
2 minor enhancements
|
80
|
+
- Speed improvements and test coverage
|
81
|
+
- Created a top-level Logging.init method that is used to
|
82
|
+
define the default logging levels
|
83
|
+
|
84
|
+
1 bug fix
|
85
|
+
- Tweaked windows detection code
|
86
|
+
|
87
|
+
== 0.6.3 / 2008-02-08
|
88
|
+
|
89
|
+
2 minor enhancements
|
90
|
+
- YAML configuration now supports multiple keys -- i.e. development
|
91
|
+
or production or whatever
|
92
|
+
- Reorganized a lot of files so that requiring files is cleaner and
|
93
|
+
more deterministic
|
94
|
+
|
95
|
+
== 0.6.2 / 2008-02-06
|
96
|
+
|
97
|
+
2 bug fixes
|
98
|
+
- An extra e-mail was being pushed out when the e-mail
|
99
|
+
appender was closed
|
100
|
+
- Created an at_exit handler to close all appenders
|
101
|
+
|
102
|
+
== 0.6.1 / 2008-01-01
|
103
|
+
|
104
|
+
1 bug fix
|
105
|
+
- Fixed include order to avoid double loading when testing
|
106
|
+
|
107
|
+
== 0.6.0 / 2007-12-26
|
108
|
+
|
109
|
+
* Using the new 'getopt' method for handling option hashes
|
110
|
+
* Rolling file appender is safe for multiple processes
|
111
|
+
* Added an e-mail appender from Jeremy Hinegardner
|
112
|
+
* Updated tests for the appenders
|
113
|
+
|
114
|
+
== 0.5.3 / 2007-12-08
|
115
|
+
|
116
|
+
* Fixed the quoting for messages sent to the growl appender
|
117
|
+
|
118
|
+
== 0.5.2 / 2007-11-28
|
119
|
+
|
120
|
+
* Updated the library to work with Ruby 1.9
|
121
|
+
* Fixed coalescing with the growl appender
|
122
|
+
|
123
|
+
== 0.5.1 / 2007-11-18
|
124
|
+
|
125
|
+
* Fixed a bug on Windows when attempting to load the syslog library
|
126
|
+
|
127
|
+
== 0.5.0 / 2007-11-18
|
128
|
+
|
129
|
+
* Added the ability to log via the syslog daemon
|
130
|
+
* Can send messages to the Growl notification system on Mac OS X
|
131
|
+
* The Growl appender can coalesce messages of the same title/priority
|
132
|
+
|
133
|
+
== 0.4.0 / 2007-03-21
|
134
|
+
|
135
|
+
* Added a microsecond flag to the Pattern layout
|
136
|
+
* All appenders write immediately upon receipt of a logging event
|
137
|
+
* Added a basic logging method that returns a logger object configured in
|
138
|
+
the same manner as the standard Ruby logger
|
139
|
+
* Fixed a bug caused by nil log messages
|
140
|
+
|
141
|
+
== 0.3.1 / 2007-02-08
|
142
|
+
|
143
|
+
* Bugfix Release
|
144
|
+
|
145
|
+
== 0.3.0 / 2007-02-01
|
146
|
+
|
147
|
+
* Remove the ability to log multiple objects from a single log method call
|
148
|
+
|
149
|
+
== 0.2.0 / 2007-01-29
|
150
|
+
|
151
|
+
* The "once every four years" release
|
152
|
+
* Storage and retrieval of appenders by name
|
153
|
+
* YAML configuration support
|
154
|
+
* Rolling file appender
|
155
|
+
|
156
|
+
== 0.1.0 / 2007-01-12
|
157
|
+
|
158
|
+
* 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,41 @@
|
|
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
|
+
|
38
|
+
depend_on 'flexmock'
|
39
|
+
depend_on 'lockfile'
|
40
|
+
|
41
|
+
# EOF
|
@@ -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
|