logjam 1.0.0 → 1.1.0
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.
- data/README +145 -91
- data/lib/logjam/logjam.rb +14 -9
- data/lib/logjam/logjam_logger2.rb +68 -0
- data/lib/logjam/object.rb +33 -0
- data/lib/logjam/version.rb +1 -1
- data/lib/logjam.rb +2 -0
- metadata +6 -4
data/README
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
LogJam
|
2
|
-
|
3
|
-
LogJam is a library that attempts to allow for the aggregation the
|
4
|
-
|
5
|
-
were...
|
1
|
+
# LogJam
|
2
|
+
|
3
|
+
LogJam is a library that attempts to allow for the aggregation and the
|
4
|
+
distribution of logging facilities across a range of classes. Goals in
|
5
|
+
creating this library were...
|
6
6
|
|
7
7
|
* Easy of use. Fall back on defaults as much as possible and allow the
|
8
8
|
functionality to be integrated and used with the least amount of work.
|
@@ -20,11 +20,11 @@ were...
|
|
20
20
|
wanted to minimize the burden this placed on library users at the same
|
21
21
|
time.
|
22
22
|
|
23
|
-
Configuration & Setup
|
24
|
-
|
25
|
-
|
26
|
-
LogJam
|
27
|
-
String, a Hash, an IO object or nil.
|
23
|
+
## Configuration & Setup
|
24
|
+
|
25
|
+
To explicitly configure the settings LogJam you make a call to the
|
26
|
+
LogJam#configure() method. This method takes a single parameter which should be
|
27
|
+
either a String, a Hash, an IO object or nil.
|
28
28
|
|
29
29
|
If you pass a String in this is expected to contain the path and name of a file
|
30
30
|
that contains the logging configuration. Logging configuration files can be
|
@@ -32,7 +32,7 @@ provided in either YAML or JSON format. If you pass an IO object this is
|
|
32
32
|
expected to be the source of the configuration and, again, this configuration
|
33
33
|
should be in either YAML or JSON format. In either case, where a String or IO
|
34
34
|
is specified, the data read must be translatable into a Hash, which brings us
|
35
|
-
to the other type that the configure() method accepts as a parameter.
|
35
|
+
to the other type that the LogJam#configure() method accepts as a parameter.
|
36
36
|
|
37
37
|
A Hash passed to the configure() method is expected to contain a set of values
|
38
38
|
that can be converted into a logging set up. Passing an empty Hash will result
|
@@ -42,37 +42,37 @@ stream being created and used by all classes that have LogJam functionality.
|
|
42
42
|
The Hash passed to the configure() method can contain two keys that the library
|
43
43
|
will recognise and use. The first of these is 'loggers', in either Symbol or
|
44
44
|
String form. The value under the loggers key is expected to be an Array
|
45
|
-
containing zero or more logger definitions.
|
46
|
-
which the following keys are recognised (either as Strings or
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
45
|
+
containing zero or more logger definitions. An individual logger definition is
|
46
|
+
itself a Hash in which the following keys are recognised (either as Strings or
|
47
|
+
Symbols) - default, datetime_format, file, level, max_size, name and rotation.
|
48
|
+
The meanings applied to these keys are as follows...
|
49
|
+
|
50
|
+
* default: A boolean indicating whether this logger is the default (i.e. the
|
51
|
+
one to be used when no other explicitly fits the bill). Only one logger
|
52
|
+
should be declared as a default.
|
53
|
+
|
54
|
+
* datetime_format: The date/time format to be used by the logger. See the
|
55
|
+
documentation for the standard Ruby Logger class for more details.
|
56
|
+
|
57
|
+
* file: The path and name of the file that logging details will be written to.
|
58
|
+
Two special values are recognised in this value. STDOUT and STDERR are
|
59
|
+
translated to mean the standard output or error streams respectively.
|
60
|
+
|
61
|
+
* level: The logging level to set on the logger. Must be one of DEBUG, INFO,
|
62
|
+
WARN, ERROR, FATAL or UNKNOWN. If not explicitly specified this defaults
|
63
|
+
to DEBUG.
|
64
|
+
|
65
|
+
* max_size: When rotation is set to an integer value this value can be set to
|
66
|
+
indicate the maximum permitted file size for a log file.
|
67
|
+
|
68
|
+
* name: The name to associate with the logger. This allows loggers to be tied
|
69
|
+
to classes or for the creation of aliases that tie multiple names to a single
|
70
|
+
logger. Note that you should always use Strings (and not Symbols) when
|
71
|
+
specifying aliases.
|
72
|
+
|
73
|
+
* rotation: The frequency with which the log file is rotated. This may be an
|
74
|
+
integer to indicate how many old log files are retained or may be a String
|
75
|
+
such as "daily", "weekly" or "monthly".
|
76
76
|
|
77
77
|
A note on logger names. Logger names (including alias names) aren't hierarchical
|
78
78
|
and should be unique.
|
@@ -84,19 +84,24 @@ alias names and the mapped values are expected to be the name of a logger
|
|
84
84
|
declared in the logger section. An entry in the aliases Hash creates an alias
|
85
85
|
for an existing logger under a different name.
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
The final parameter option when calling LogJam#configure() is to pass a nil to
|
88
|
+
the method. If you pass nil to the configure method it behaves in a slightly
|
89
|
+
different fashion. In this case the method searches for a configuration file
|
90
|
+
that it can use given a default set of files names (logging.yaml, logging.yml
|
91
|
+
and logging.json in the current working directory and in a subdirectory of the
|
91
92
|
current working directory called config). The first of these files that it finds
|
92
93
|
it attempts to use as configuration for the logging set up. If it doesn't find
|
93
94
|
a configuration file then this type of call becomes equivalent to passing an
|
94
|
-
empty Hash to the configure() method.
|
95
|
+
empty Hash to the configure() method. As of version 1.1.0 the library includes
|
96
|
+
an implicit call to LogJam#configure(nil) removing the need to do this
|
97
|
+
explicitly in your own code.
|
95
98
|
|
96
|
-
|
99
|
+
Note that you can call LogJam#configure multiple times, with each successive
|
100
|
+
call overwriting and replacing the details of previous calls. See the end of
|
101
|
+
this document for some example configurations.
|
102
|
+
|
103
|
+
## Logging With The Library
|
97
104
|
|
98
|
-
Logging With The Library
|
99
|
-
------------------------
|
100
105
|
The stated goals of the LogJam library are to avoid the need to pass Logger
|
101
106
|
instances around while still allowing potentially complex configuration with a
|
102
107
|
minimum of code. The first step in this process has been covered in the
|
@@ -105,42 +110,60 @@ from a single Hash or file. This section will provide details on how to deploy
|
|
105
110
|
loggers to various classes.
|
106
111
|
|
107
112
|
The LogJam library works by providing an extension to any class that uses it
|
108
|
-
that provides access to the logger to be used by the class.
|
109
|
-
|
110
|
-
|
111
|
-
|
113
|
+
that provides access to the logger to be used by the class. As of version 1.1.0
|
114
|
+
LogJam applies itself as an extension to the Ruby Object class, making the
|
115
|
+
logging facilities it provides available in any object. Prior to v1.1.0 you had
|
116
|
+
to make a call the apply() method of the LogJam module inside your class
|
117
|
+
definition. A typical call of this type might look like...
|
118
|
+
|
119
|
+
```
|
120
|
+
# Apply logging facilties to my class.
|
112
121
|
LogJam.apply(self, "my_logger")
|
122
|
+
```
|
113
123
|
|
114
|
-
This
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
This option remains available for backward compatibility but is no longer
|
125
|
+
needed. A line like this would appear somewhere inside the definition for the
|
126
|
+
class that will use logging. The first parameter to the call is the class that
|
127
|
+
is to be extended with the LogJam functionality. The second parameter is the
|
128
|
+
name of the logger that the class will use. Note that this parameter is optional
|
129
|
+
and, if notspecified or if a matching logger does not exist, the class will fall
|
130
|
+
back in using the default logger.
|
131
|
+
|
132
|
+
From version 1.1.0 onward you no longer need to call apply. Instead LogJams
|
133
|
+
logging facilities are available in all objects. This change means that all
|
134
|
+
classes use the default logger as standard. If you want to continue to use an
|
135
|
+
explitictly named logger on a per class basis you can make a call to the
|
136
|
+
LogJam#set_logger_name() method within your class definitions. This is similar
|
137
|
+
in nature to how the apply method was used and so would look something like the
|
138
|
+
following...
|
139
|
+
|
140
|
+
```
|
141
|
+
# Use an explicitly named logger for my class.
|
142
|
+
set_logger_name "my_logger"
|
143
|
+
```
|
144
|
+
|
145
|
+
LogJams logging facilities consist of two class level methods (one called log()
|
146
|
+
and one called log=()) and an instance level method called log(). The log()
|
147
|
+
methods retrieve the Logger instance to be used by the class instances. The
|
148
|
+
log=() method allows the Logger instance associated with a class to be altered.
|
149
|
+
You should take care when assigning a logger in this fashion as assigning it
|
150
|
+
on one class may have an impact on many classes (e.g. if there is only a single
|
151
|
+
default logger defined in configuration).
|
128
152
|
|
129
153
|
The following complete (although contrived) example gives an overview of how
|
130
154
|
this would work...
|
131
155
|
|
156
|
+
```
|
132
157
|
require 'rubygems'
|
133
158
|
require 'logjam'
|
134
159
|
|
135
160
|
class Writer
|
136
|
-
LogJam.apply(self, "echo")
|
137
|
-
|
138
161
|
def initialize(stream=STDOUT)
|
139
162
|
@stream = stream
|
140
163
|
end
|
141
164
|
|
142
165
|
def echo(message)
|
143
|
-
|
166
|
+
log.debug("Echoed: #{message}")
|
144
167
|
@stream.puts message
|
145
168
|
end
|
146
169
|
end
|
@@ -154,25 +177,25 @@ this would work...
|
|
154
177
|
rescue => error
|
155
178
|
puts "ERROR: #{error}\n" + error.backtrace.join("\n")
|
156
179
|
end
|
180
|
+
```
|
157
181
|
|
158
182
|
In this example we create a Writer class that can echo a String on a stream. In
|
159
|
-
doing this it also logs the message echoed at the debug level. We
|
160
|
-
|
161
|
-
the echo() method, we can simply call Writer.log() to get the class logger.
|
183
|
+
doing this it also logs the message echoed at the debug level. We can simply
|
184
|
+
call the log() method to get the class logger.
|
162
185
|
|
163
186
|
In the later section of the code we configure the LogJam system to have a single
|
164
187
|
Logger that writes to the echo.log file. We then create a Writer instance and
|
165
188
|
use it to write a simple message. This message should appear on the standard
|
166
189
|
output stream and be logged to the echo.log file.
|
190
|
+
|
191
|
+
## Advanced Usage
|
167
192
|
|
168
|
-
Advanced Usage
|
169
|
-
--------------
|
170
193
|
The hope would be that this library can be used in the creation of other
|
171
194
|
libraries and allow for control of the logging generated by those libraries
|
172
195
|
without having to dig into the workings of the library or to pass around Logger
|
173
|
-
instances
|
174
|
-
explicitly declaring logger names
|
175
|
-
|
196
|
+
instances as constructor parameters or static data. In this case I recommend
|
197
|
+
explicitly declaring logger names for your library classes and making the name
|
198
|
+
that the library uses available with the library documentation so that the
|
176
199
|
libraries logging can be switched off or on as needed.
|
177
200
|
|
178
201
|
It's intended that, in general, the configure() method on the LogJam module
|
@@ -198,8 +221,8 @@ Finally, any logger can be fetched from the library using it's name and making
|
|
198
221
|
a call to the LogJam.get_logger() method. Note if you omit the name or pass in
|
199
222
|
nil you will retrieve the libraries default logger.
|
200
223
|
|
201
|
-
Example Configurations
|
202
|
-
|
224
|
+
## Example Configurations
|
225
|
+
|
203
226
|
This section contains some example configurations. A short explanation is given
|
204
227
|
for each configuration and then the configuration itself in Hash, YAML and JSON
|
205
228
|
formats is provided.
|
@@ -209,31 +232,41 @@ to the configure method the system creates a single, default logger that writes
|
|
209
232
|
everything on the standard output stream...
|
210
233
|
|
211
234
|
Hash
|
235
|
+
```
|
212
236
|
{}
|
213
|
-
|
237
|
+
```
|
238
|
+
|
214
239
|
YAML
|
215
|
-
|
240
|
+
```
|
216
241
|
{}
|
242
|
+
```
|
217
243
|
|
218
244
|
JSON
|
245
|
+
```
|
219
246
|
{}
|
247
|
+
```
|
220
248
|
|
221
249
|
The following simple configuration writes all logging output to a file called
|
222
250
|
application.log in the current working directory. If a logging level is not
|
223
251
|
explicitly specified then DEBUG is the default...
|
224
252
|
|
225
253
|
Hash
|
254
|
+
```
|
226
255
|
{:loggers => [{:default => true, :file => "application.log"}]}
|
256
|
+
```
|
227
257
|
|
228
258
|
YAML
|
229
|
-
|
259
|
+
```
|
230
260
|
:loggers:
|
231
261
|
- :default: true
|
232
262
|
:file: application.log
|
263
|
+
```
|
233
264
|
|
234
265
|
JSON
|
266
|
+
```
|
235
267
|
{"loggers": {"default": true, "file": "application.log"}}
|
236
|
-
|
268
|
+
```
|
269
|
+
|
237
270
|
This configuration declares two loggers. The first is called 'silent' and will
|
238
271
|
log nothing. The silent logger is the default and so will be used for any class
|
239
272
|
that doesn't have an explicitly named logger. The second is called 'verbose' and
|
@@ -243,6 +276,7 @@ the verbose logger. An class that declares it uses the 'database' logger will
|
|
243
276
|
generate output while all others will be silenced.
|
244
277
|
|
245
278
|
Hash
|
279
|
+
```
|
246
280
|
{:loggers => [{:default => true,
|
247
281
|
:file => "STDOUT",
|
248
282
|
:level => "UNKNOWN",
|
@@ -250,9 +284,10 @@ Hash
|
|
250
284
|
{:file => "STDOUT",
|
251
285
|
:name => "verbose"}],
|
252
286
|
:aliases => {"database" => "verbose"}}
|
287
|
+
```
|
253
288
|
|
254
289
|
YAML
|
255
|
-
|
290
|
+
```
|
256
291
|
:loggers:
|
257
292
|
- :default: true
|
258
293
|
:file: STDOUT
|
@@ -262,8 +297,10 @@ YAML
|
|
262
297
|
:name: verbose
|
263
298
|
:aliases:
|
264
299
|
database: verbose
|
300
|
+
```
|
265
301
|
|
266
302
|
JSON
|
303
|
+
```
|
267
304
|
{"loggers": [{"default":true,
|
268
305
|
"file": "STDOUT",
|
269
306
|
"level": "UNKNOWN",
|
@@ -271,6 +308,7 @@ JSON
|
|
271
308
|
{"file": "STDOUT",
|
272
309
|
"name": "verbose"}],
|
273
310
|
"aliases": {"database":"verbose"}}
|
311
|
+
```
|
274
312
|
|
275
313
|
The following configuration can be used as an example of how to drive logging
|
276
314
|
from different parts of the code to different destinations. The configuration
|
@@ -279,6 +317,7 @@ then declares aliases for those loggers that can be used to divide up the
|
|
279
317
|
logging coming from different areas of the code.
|
280
318
|
|
281
319
|
Hash
|
320
|
+
```
|
282
321
|
{:loggers => [{:default => true,
|
283
322
|
:file => "./log/main.log",
|
284
323
|
:name => "main"},
|
@@ -287,9 +326,10 @@ Hash
|
|
287
326
|
:aliases => {"database" => "secondary",
|
288
327
|
"model" => "secondary",
|
289
328
|
"controller" => "main"}}
|
329
|
+
```
|
290
330
|
|
291
331
|
YAML
|
292
|
-
|
332
|
+
```
|
293
333
|
:loggers:
|
294
334
|
- :default: true
|
295
335
|
:file: ./log/main.log
|
@@ -300,8 +340,10 @@ YAML
|
|
300
340
|
database: secondary
|
301
341
|
model: secondary
|
302
342
|
controller: main
|
343
|
+
```
|
303
344
|
|
304
345
|
JSON
|
346
|
+
```
|
305
347
|
{"loggers": [{"default":true,
|
306
348
|
"file": "./log/main.log",
|
307
349
|
"name": "main"},
|
@@ -310,12 +352,24 @@ JSON
|
|
310
352
|
"aliases": {"database":"secondary",
|
311
353
|
"model": "secondary",
|
312
354
|
"controller": "main"}}
|
355
|
+
```
|
356
|
+
|
357
|
+
## Testing
|
313
358
|
|
314
|
-
|
315
|
-
-------
|
316
|
-
LogJam uses the test-unit Ruby library for testing. The best approach to running
|
359
|
+
LogJam uses the minitest Ruby library for testing. The best approach to running
|
317
360
|
the tests are to create a new gemset (assuming you're using RVM), do a bundle
|
318
361
|
install on this gemset from within the LogJam root directory and then use a
|
319
362
|
command such as the following to run the tests...
|
320
363
|
|
321
|
-
|
364
|
+
```
|
365
|
+
$> rake test:unit
|
366
|
+
```
|
367
|
+
|
368
|
+
Individual tests can be run by including a definition for TESTS which contains
|
369
|
+
a comma separated_list of the tests to be run. For example...
|
370
|
+
|
371
|
+
```
|
372
|
+
$> rake test:unit TESTS=object,apply
|
373
|
+
```
|
374
|
+
|
375
|
+
...would run only the object and apply tests.
|
data/lib/logjam/logjam.rb
CHANGED
@@ -27,8 +27,9 @@ module LogJam
|
|
27
27
|
".#{File::SEPARATOR}config#{File::SEPARATOR}logging.json"]
|
28
28
|
|
29
29
|
# Module static properties.
|
30
|
-
@@logjam_modules
|
31
|
-
@@logjam_loggers
|
30
|
+
@@logjam_modules = {}
|
31
|
+
@@logjam_loggers = {}
|
32
|
+
@@logjam_contexts = {}
|
32
33
|
|
33
34
|
# This method is used to configure the LogJam module with the various loggers
|
34
35
|
# it will use.
|
@@ -64,11 +65,14 @@ module LogJam
|
|
64
65
|
# classes that use the same logger.
|
65
66
|
#
|
66
67
|
# ==== Parameters
|
67
|
-
# target::
|
68
|
-
# name::
|
69
|
-
#
|
70
|
-
|
71
|
-
|
68
|
+
# target:: The target class that is to be extended.
|
69
|
+
# name:: The name of the logger to be used by the class. Defaults to nil
|
70
|
+
# to indicate use of the default logger.
|
71
|
+
# context:: A Hash of additional parameters that are specific to the class
|
72
|
+
# to which LogJam is being applied.
|
73
|
+
def self.apply(target, name=nil, context={})
|
74
|
+
@@logjam_contexts[target] = {}.merge(context)
|
75
|
+
target.extend(LogJam.get_module(name, @@logjam_contexts[target]))
|
72
76
|
target.send(:define_method, :log) {LogJam.get_logger(name)} if !target.method_defined?(:log)
|
73
77
|
end
|
74
78
|
|
@@ -100,8 +104,9 @@ module LogJam
|
|
100
104
|
# not exist the default module is returned instead.
|
101
105
|
#
|
102
106
|
# ==== Parameters
|
103
|
-
# name::
|
104
|
-
|
107
|
+
# name:: The name associated with the module to return.
|
108
|
+
# context:: The context that applies to the module to be retrieved.
|
109
|
+
def self.get_module(name, context={})
|
105
110
|
LogJam.create_module(name)
|
106
111
|
end
|
107
112
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c), 2012 Peter Wood
|
4
|
+
# See the license.txt for details of the licensing of the code in this file.
|
5
|
+
|
6
|
+
module LogJam
|
7
|
+
# This class represents a specialization of the Ruby Logger class. The class
|
8
|
+
# retains a Ruby Logger instance within itself and delegates all standard
|
9
|
+
# logger calls to this instance. This allows for changes to the underlying
|
10
|
+
# logger without changing the containing one, thus bypassing people caching
|
11
|
+
# an instance.
|
12
|
+
class LogJamLogger < Logger
|
13
|
+
# Constructor for the LogJamLogger class. All parameters are passed
|
14
|
+
# straight through to create a standard Ruby Logger instance except
|
15
|
+
# when the first parameter is a Logger instance. In this case the
|
16
|
+
# Logger passed in is used rather than creating a new one.
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# logdev:: The log device to be used by the logger. This should
|
20
|
+
# either be a String containing a file path/name or an IO
|
21
|
+
# object that the logging details will be written to.
|
22
|
+
# shift_age:: The maximum number of old log files to retain or a String
|
23
|
+
# containing the rotation frequency for the log.
|
24
|
+
# shift_size:: The maximum size that the loggin output will be allowed
|
25
|
+
# to grow to before rotation occurs.
|
26
|
+
def initialize(logdev, shift_age=0, shift_size=1048576)
|
27
|
+
@log = (logdev.kind_of?(Logger) ? logdev : Logger.new(logdev, shift_age, shift_size))
|
28
|
+
@name = nil
|
29
|
+
@prefixes = {}
|
30
|
+
self.formatter = @log.formatter
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute accessor/mutator declaration.
|
34
|
+
attr_accessor :name, :prefixes
|
35
|
+
|
36
|
+
# A definition of the method_missing method that passes all otherwise
|
37
|
+
# undefined method calls on to the contained logger instance.
|
38
|
+
#
|
39
|
+
# ==== Parameters
|
40
|
+
# method:: A Symbol containing the name of the method that was
|
41
|
+
# invoked but found to be missing.
|
42
|
+
# *arguments:: An array containing the arguments that were passed
|
43
|
+
# to the method call.
|
44
|
+
# &block:: Any block passed to the method call.
|
45
|
+
def method_missing(method, *arguments, &block)
|
46
|
+
if @log.responds_to? method
|
47
|
+
@log.send(method, *arguments, &block)
|
48
|
+
else
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# This method replaces the formatter assignment method on the logger
|
54
|
+
# to allow the addition of custom fields.
|
55
|
+
#
|
56
|
+
# ==== Parameters
|
57
|
+
# &block:: The block that contains the standard formatter to be
|
58
|
+
# set on the logger.
|
59
|
+
def formatter=(&block)
|
60
|
+
@log.formatter = proc do |severity, timestamp, program, message|
|
61
|
+
if @prefixes.include?(severity) || @prefixes.include?(:default)
|
62
|
+
message = "[#{(@prefixes[severity] || @prefixes[:default])}] #{message}"
|
63
|
+
end
|
64
|
+
block.call(severity, timestamp, program, message)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c), 2013 Peter Wood
|
4
|
+
# See the license.txt for details of the licensing of the code in this file.
|
5
|
+
|
6
|
+
class Object
|
7
|
+
# This method provides an instance level accessor to obtain a logger. Unless
|
8
|
+
# a name is specified the logger returned is the default one.
|
9
|
+
def log
|
10
|
+
LogJam.get_logger
|
11
|
+
end
|
12
|
+
|
13
|
+
# This method provides a class level accessor to obtain a logger. Unless a
|
14
|
+
# name is specified the logger returned is the default one.
|
15
|
+
def self.log
|
16
|
+
LogJam.get_logger
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.log=(logger)
|
20
|
+
LogJam.get_logger.logger = logger
|
21
|
+
end
|
22
|
+
|
23
|
+
# This method allows a class to specify the name of the logger that it uses
|
24
|
+
# once, generally within the class definition.
|
25
|
+
#
|
26
|
+
# ==== Parameters
|
27
|
+
# name:: The name of the logger used by the class.
|
28
|
+
# context:: A Hash of additional parameters that are specific to the class
|
29
|
+
# to which LogJam is being applied.
|
30
|
+
def self.set_logger_name(name, context={})
|
31
|
+
LogJam.apply(self, name, context)
|
32
|
+
end
|
33
|
+
end
|
data/lib/logjam/version.rb
CHANGED
data/lib/logjam.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -35,9 +35,11 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- lib/logjam/version.rb
|
38
|
-
- lib/logjam/logjam_logger.rb
|
39
38
|
- lib/logjam/logjam.rb
|
40
39
|
- lib/logjam/exceptions.rb
|
40
|
+
- lib/logjam/logjam_logger.rb
|
41
|
+
- lib/logjam/object.rb
|
42
|
+
- lib/logjam/logjam_logger2.rb
|
41
43
|
- lib/logjam.rb
|
42
44
|
- license.txt
|
43
45
|
- README
|
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
63
|
version: '0'
|
62
64
|
requirements: []
|
63
65
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.8.
|
66
|
+
rubygems_version: 1.8.25
|
65
67
|
signing_key:
|
66
68
|
specification_version: 3
|
67
69
|
summary: A library to aggregate logging.
|