logging 1.6.1 → 1.6.2

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/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ # git-ls-files --others --exclude-from=.git/info/exclude
2
+ # Lines that start with '#' are comments.
3
+ # For a project mostly in C, the following would be a good set of
4
+ # exclude patterns (uncomment them if you want to use them):
5
+ # *.[oa]
6
+ # *~
7
+ announcement.txt
8
+ coverage/
9
+ doc/
10
+ pkg/
11
+ tmp/
12
+ .rbx
data/.rvmrc ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p290@logging"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+
14
+ #
15
+ # First we attempt to load the desired environment directly from the environment
16
+ # file. This is very fast and efficient compared to running through the entire
17
+ # CLI and selector. If you want feedback on which environment was used then
18
+ # insert the word 'use' after --create as this triggers verbose mode.
19
+ #
20
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
21
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
22
+ then
23
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
24
+
25
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
26
+ then
27
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
28
+ fi
29
+ else
30
+ # If the environment file has not yet been created, use the RVM CLI to select.
31
+ if ! rvm --create "$environment_id"
32
+ then
33
+ echo "Failed to create RVM environment '${environment_id}'."
34
+ exit 1
35
+ fi
36
+ fi
37
+
38
+ #
39
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
40
+ # it be automatically loaded. Uncomment the following and adjust the filename if
41
+ # necessary.
42
+ #
43
+ # filename=".gems"
44
+ # if [[ -s "$filename" ]] ; then
45
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
46
+ # fi
47
+
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ == 1.6.2 / 2012-01-05
2
+
3
+ Bug Fixes
4
+ - Fix typo in the Readme [issue #14]
5
+ - Fix spelling in a variety of places [issue #15]
6
+ - Solaris does not have Syslog#LOG_PERROR defined [issue #17]
7
+ - Fix failing tests for Ruby 1.9.3 [issue #18]
8
+ - Check for RUBY_ENGINE for Ruby 1.8.7 [issue #19]
9
+ - Whitespace and '# EOF' cleanup
10
+ - Support for Rubinious
11
+
1
12
  == 1.6.1 / 2011-09-09
2
13
 
3
14
  Bug Fixes
data/README.rdoc CHANGED
@@ -30,7 +30,7 @@ logged.
30
30
  logger.debug "this debug message will not be output by the logger"
31
31
  logger.warn "this is your last warning"
32
32
 
33
- In this example, a single logger is crated that will append to STDOUT and to a
33
+ In this example, a single logger is created that will append to STDOUT and to a
34
34
  file. Only log messages that are informational or higher will be logged.
35
35
 
36
36
  require 'logging'
data/examples/fork.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # :stopdoc:
2
2
  #
3
3
  # Because of the global interpreter lock, Kernel#fork is the best way
4
- # to acheive true concurrency in Ruby scripts. However, there are pecularities
5
- # when using frok and passing file descriptors between process. These
6
- # pecularities affect the logging framework.
4
+ # to achieve true concurrency in Ruby scripts. However, there are peculiarities
5
+ # when using fork and passing file descriptors between process. These
6
+ # peculiarities affect the logging framework.
7
7
  #
8
8
  # In short, always reopen file descriptors in the child process after fork has
9
9
  # been called. The RollingFile appender uses flock to safely coordinate the
data/examples/simple.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Logging provides a simple, default logger configured in the same manner as
4
4
  # the default Ruby Logger class -- i.e. the output of the two will be the
5
- # same. All log messags at "warn" or higher are printed to STDOUT; any
5
+ # same. All log messages at "warn" or higher are printed to STDOUT; any
6
6
  # message below the "warn" level are discarded.
7
7
  #
8
8
 
data/lib/logging.rb CHANGED
@@ -192,8 +192,8 @@ module Logging
192
192
  #
193
193
  # If the "root" logger name is passed to this method then all loggers
194
194
  # will consolidate to the root logger. In other words, only the root
195
- # logger will be created, and it will be used by all classes and moduels
196
- # in the applicaiton.
195
+ # logger will be created, and it will be used by all classes and modules
196
+ # in the application.
197
197
  #
198
198
  # ==== Example
199
199
  #
@@ -363,7 +363,7 @@ module Logging
363
363
  end
364
364
 
365
365
  # Returns the library path for the module. If any arguments are given,
366
- # they will be joined to the end of the libray path using
366
+ # they will be joined to the end of the library path using
367
367
  # <tt>File.join</tt>.
368
368
  #
369
369
  def libpath( *args, &block )
@@ -419,7 +419,7 @@ module Logging
419
419
  #
420
420
  # 1) name - the name of the logger
421
421
  #
422
- # 2) level - the logger level; if it is preceeded by an
422
+ # 2) level - the logger level; if it is preceded by an
423
423
  # asterisk then the level was explicitly set for that
424
424
  # logger (as opposed to being inherited from the parent
425
425
  # logger)
@@ -470,7 +470,7 @@ module Logging
470
470
  end
471
471
 
472
472
  # :stopdoc:
473
- # Convert the given level into a connaconical form - a lowercase string.
473
+ # Convert the given level into a canonical form - a lowercase string.
474
474
  def levelify( level )
475
475
  case level
476
476
  when String; level.downcase
@@ -122,7 +122,7 @@ class Appender
122
122
  # appender.level = 'off'
123
123
  # appender.level = :all
124
124
  #
125
- # These prodcue an +ArgumentError+
125
+ # These produce an +ArgumentError+
126
126
  #
127
127
  # appender.level = Object
128
128
  # appender.level = -1
@@ -257,4 +257,3 @@ private
257
257
  end # class Appender
258
258
  end # module Logging
259
259
 
260
- # EOF
@@ -74,7 +74,7 @@ module Logging
74
74
  # call-seq:
75
75
  # Appenders[name]
76
76
  #
77
- # Returns the appender instance stroed in the appender hash under the
77
+ # Returns the appender instance stored in the appender hash under the
78
78
  # key _name_, or +nil+ if no appender has been created using that name.
79
79
  #
80
80
  def []( name ) @appenders[name] end
@@ -134,4 +134,3 @@ Logging.libpath {
134
134
  require 'logging/appenders/syslog'
135
135
  }
136
136
 
137
- # EOF
@@ -43,7 +43,7 @@ module Logging::Appenders
43
43
  super(*args, &block)
44
44
  end
45
45
 
46
- # Close the message buffer by flusing all log events to the appender. If a
46
+ # Close the message buffer by flushing all log events to the appender. If a
47
47
  # periodic flusher thread is running, shut it down and allow it to exit.
48
48
  #
49
49
  def close( *args )
@@ -58,7 +58,7 @@ module Logging::Appenders
58
58
  super(*args)
59
59
  end
60
60
 
61
- # Reopen the connection to the underlying logging destination. In addtion
61
+ # Reopen the connection to the underlying logging destination. In addition
62
62
  # if the appender is configured for periodic flushing, then the flushing
63
63
  # thread will be stopped and restarted.
64
64
  #
@@ -91,8 +91,8 @@ module Logging::Appenders
91
91
  # even though it is a higher level. Both must be explicitly passed to
92
92
  # this assignment.
93
93
  #
94
- # You can pass in a single leveal name or number, and array of level
95
- # names or numbers, or a string containg a comma separated list of level
94
+ # You can pass in a single level name or number, an array of level
95
+ # names or numbers, or a string containing a comma separated list of level
96
96
  # names or numbers.
97
97
  #
98
98
  # immediate_at = :error
@@ -132,8 +132,8 @@ module Logging::Appenders
132
132
  # nil OR
133
133
  # 0 : only flush when the buffer is full (500 messages)
134
134
  #
135
- # If the default buffer size of 500 is too small, you can manuall
136
- # configure to be as large as you want. This will consume more memory.
135
+ # If the default buffer size of 500 is too small, then you can manually
136
+ # configure it to be as large as you want. This will consume more memory.
137
137
  #
138
138
  # auto_flushing = 42_000
139
139
  #
@@ -274,7 +274,7 @@ module Logging::Appenders
274
274
 
275
275
  # Using the flush_period, create a new PeriodicFlusher attached to this
276
276
  # appender. If the flush_period is nil, then no action will be taken. If a
277
- # PeriodicFlusher alreayd exists, it will be stopped and a new one will be
277
+ # PeriodicFlusher already exists, it will be stopped and a new one will be
278
278
  # created.
279
279
  #
280
280
  def _setup_periodic_flusher
@@ -22,7 +22,7 @@ module Logging::Appenders
22
22
  #
23
23
  def initialize( *args )
24
24
  opts = Hash === args.last ? args.pop : {}
25
- name = args.empty? ? 'stdout' : args.shift
25
+ name = args.empty? ? 'stdout' : args.shift
26
26
 
27
27
  super(name, STDOUT, opts)
28
28
  end
@@ -49,7 +49,7 @@ module Logging::Appenders
49
49
  #
50
50
  def initialize( *args )
51
51
  opts = Hash === args.last ? args.pop : {}
52
- name = args.empty? ? 'stderr' : args.shift
52
+ name = args.empty? ? 'stderr' : args.shift
53
53
 
54
54
  super(name, STDERR, opts)
55
55
  end
@@ -57,4 +57,3 @@ module Logging::Appenders
57
57
 
58
58
  end # module Logging::Appenders
59
59
 
60
- # EOF
@@ -2,7 +2,7 @@
2
2
  require 'net/smtp'
3
3
  require 'time' # get rfc822 time format
4
4
 
5
- # a replacement EmailOutputter. This is essentially the default EmailOutptter from Log4r but with the following
5
+ # a replacement EmailOutputter. This is essentially the default EmailOutputter from Log4r but with the following
6
6
  # changes:
7
7
  # 1) if there is data to send in an email, then do not send anything
8
8
  # 2) connect to the smtp server at the last minute, do not connect at startup and then send later on.
@@ -37,7 +37,7 @@ module Logging::Appenders
37
37
  # logging destination. If the file does not already exist it will be
38
38
  # created. If the :truncate option is set to +true+ then the file will
39
39
  # be truncated before writing begins; otherwise, log messages will be
40
- # appened to the file.
40
+ # appended to the file.
41
41
  #
42
42
  def initialize( name, opts = {} )
43
43
  @fn = opts.getopt(:filename, name)
@@ -73,4 +73,3 @@ module Logging::Appenders
73
73
  end # class FileAppender
74
74
  end # module Logging::Appenders
75
75
 
76
- # EOF
@@ -49,7 +49,7 @@ module Logging::Appenders
49
49
  # notification levels. This is needed in order to log events at the
50
50
  # proper Growl level.
51
51
  #
52
- # Without any configuration, the following maping will be used:
52
+ # Without any configuration, the following mapping will be used:
53
53
  #
54
54
  # :debug => -2
55
55
  # :info => -1
@@ -73,7 +73,7 @@ module Logging::Appenders
73
73
  # write( event )
74
74
  #
75
75
  # Write the given _event_ to the growl notification facility. The log
76
- # event will be processed through the Layout assciated with this
76
+ # event will be processed through the Layout associated with this
77
77
  # appender. The message will be logged at the level specified by the
78
78
  # event.
79
79
  #
@@ -145,7 +145,7 @@ module Logging::Appenders
145
145
  qmsg = @c_queue.last
146
146
  if qmsg.first != msg.first or qmsg.last != msg.last
147
147
  @c_queue << msg
148
- else
148
+ else
149
149
  qmsg[1] << "\n" << msg[1]
150
150
  end
151
151
  end
@@ -194,4 +194,3 @@ module Logging::Appenders
194
194
  end # class Growl
195
195
  end # module Logging::Appenders
196
196
 
197
- # EOF
@@ -49,7 +49,7 @@ module Logging::Appenders
49
49
  unless [STDIN, STDERR, STDOUT].include?(io)
50
50
  io.send(@close_method) if @close_method and io.respond_to? @close_method
51
51
  end
52
- rescue IOError => err
52
+ rescue IOError
53
53
  ensure
54
54
  return self
55
55
  end
@@ -256,7 +256,7 @@ module Logging::Appenders
256
256
 
257
257
  files = Dir.glob(@glob).find_all {|fn| @rgxp =~ fn}
258
258
  unless files.empty?
259
- # sort the files in revese order based on their count number
259
+ # sort the files in reverse order based on their count number
260
260
  files = files.sort do |a,b|
261
261
  a = Integer(@rgxp.match(a)[1])
262
262
  b = Integer(@rgxp.match(b)[1])
@@ -274,7 +274,7 @@ module Logging::Appenders
274
274
  end
275
275
  end
276
276
 
277
- # finally reanme the copied log file
277
+ # finally rename the copied log file
278
278
  ::File.rename(@fn_copy, sprintf(@logname_fmt, 1))
279
279
  ensure
280
280
  @roll = false
@@ -307,7 +307,7 @@ module Logging::Appenders
307
307
  def roll_files
308
308
  return unless @roll and ::File.exist?(@fn_copy)
309
309
 
310
- # reanme the copied log file
310
+ # rename the copied log file
311
311
  ::File.rename(@fn_copy, Time.now.strftime(@logname_fmt))
312
312
 
313
313
  # prune old log files
@@ -12,7 +12,7 @@ module Logging::Appenders
12
12
  # call-seq:
13
13
  # StringIo.new( name, opts = {} )
14
14
  #
15
- # Creates a new StrinIo appender that will append log messages to a
15
+ # Creates a new StringIo appender that will append log messages to a
16
16
  # StringIO instance.
17
17
  #
18
18
  def initialize( name, opts = {} )
@@ -39,7 +39,7 @@ module Logging::Appenders
39
39
  # which file descriptors are allocated.
40
40
  #
41
41
  # LOG_PERROR Write the message to standard error output as well to
42
- # the system log.
42
+ # the system log. Not available on Solaris.
43
43
  #
44
44
  # LOG_PID Log the process id with each message: useful for
45
45
  # identifying instantiations of daemons.
@@ -107,7 +107,7 @@ module Logging::Appenders
107
107
  # Configure the mapping from the Logging levels to the syslog levels.
108
108
  # This is needed in order to log events at the proper syslog level.
109
109
  #
110
- # Without any configuration, the following maping will be used:
110
+ # Without any configuration, the following mapping will be used:
111
111
  #
112
112
  # :debug => LOG_DEBUG
113
113
  # :info => LOG_INFO
@@ -127,7 +127,7 @@ module Logging::Appenders
127
127
  # call-seq:
128
128
  # close
129
129
  #
130
- # Closes the connetion to the syslog facility.
130
+ # Closes the connection to the syslog facility.
131
131
  #
132
132
  def close( footer = true )
133
133
  super
@@ -168,7 +168,7 @@ module Logging::Appenders
168
168
  # write( event )
169
169
  #
170
170
  # Write the given _event_ to the syslog facility. The log event will be
171
- # processed through the Layout assciated with this appender. The message
171
+ # processed through the Layout associated with this appender. The message
172
172
  # will be logged at the level specified by the event.
173
173
  #
174
174
  def write( event )
@@ -207,4 +207,3 @@ module Logging::Appenders
207
207
  end # module Logging::Appenders
208
208
  end # HAVE_SYSLOG
209
209
 
210
- # EOF
@@ -17,13 +17,13 @@ module Logging
17
17
  # ColorScheme objects are used by the Pattern layout code to colorize log
18
18
  # messages. Each color scheme is given a unique name which is used by the
19
19
  # Pattern layout to lookup the appropriate color scheme to use. Please
20
- # refere to the Pattern layout documentation for more details - specifically
20
+ # refer to the Pattern layout documentation for more details - specifically
21
21
  # the initializer documentation.
22
22
  #
23
23
  # The color scheme can be applied to the Pattern layout in several ways.
24
24
  # Each token in the log pattern can be colorized with the log level (debug,
25
25
  # info, warn, etc) receiving unique colors based on the level itself.
26
- # Another option is to colorize the enitre log message based on the log
26
+ # Another option is to colorize the entire log message based on the log
27
27
  # level; in this mode tokens do not get their own colors. Please see the
28
28
  # ColorScheme initializer for the list of colorization options.
29
29
  #
@@ -71,7 +71,7 @@ module Logging
71
71
  # end of this file. Multiple color codes can be aliased by grouping them
72
72
  # in an array as shown in the example above.
73
73
  #
74
- # Since color schems are primary inteneded to be used with the Pattern
74
+ # Since color schemes are primary intended to be used with the Pattern
75
75
  # layout, there are a few special options of note. First the log levels
76
76
  # are enumerated in their own hash:
77
77
  #
@@ -85,7 +85,7 @@ module Logging
85
85
  #
86
86
  # The log level token will be colorized differently based on the value of
87
87
  # the log level itself. Similarly the entire log message can be colorized
88
- # based on the value of the log level. A dfferent option should be given
88
+ # based on the value of the log level. A different option should be given
89
89
  # for this behavior:
90
90
  #
91
91
  # :lines => {
@@ -10,7 +10,7 @@ module Logging::Config
10
10
  class Error < StandardError; end # :nodoc:
11
11
 
12
12
  # call-seq:
13
- # Configuraotr.process( &block )
13
+ # Configurator.process( &block )
14
14
  #
15
15
  def self.process( &block )
16
16
  new.load(&block)
@@ -79,7 +79,7 @@ module Logging::Config
79
79
  ary.each do |name, config|
80
80
  l = Logging::Logger[name]
81
81
  l.level = config[:level] if config[:level]
82
- l.additive = config[:additive] if l.respond_to? :additive=
82
+ l.additive = config[:additive] if l.respond_to? :additive=
83
83
  l.trace = config[:trace]
84
84
  l.appenders = Array(config[:appenders]).
85
85
  map {|nm| ::Logging::Appenders[nm]}
@@ -105,7 +105,7 @@ module Logging::Config
105
105
 
106
106
  clazz = ::Logging::Appenders.const_get type
107
107
  clazz.new(name, config)
108
- rescue NameError => err
108
+ rescue NameError
109
109
  raise Error, "unknown appender class Logging::Appenders::#{type}"
110
110
  end
111
111
 
@@ -125,7 +125,7 @@ module Logging::Config
125
125
 
126
126
  clazz = ::Logging::Layouts.const_get type
127
127
  clazz.new config
128
- rescue NameError => err
128
+ rescue NameError
129
129
  raise Error, "unknown layout class Logging::Layouts::#{type}"
130
130
  end
131
131
 
@@ -185,4 +185,3 @@ module Logging::Config
185
185
  end # class Configurator
186
186
  end # module Logging::Config
187
187
 
188
- # EOF
@@ -188,4 +188,3 @@ module Logging::Config
188
188
  end # class YamlConfigurator
189
189
  end # module Logging::Config
190
190
 
191
- # EOF
@@ -1,4 +1,4 @@
1
-
1
+
2
2
  module Logging
3
3
 
4
4
  # The +Layout+ class provides methods for formatting log events into a
@@ -14,7 +14,7 @@ class Layout
14
14
  # call-seq:
15
15
  # Layout.new( :format_as => :string )
16
16
  #
17
- # Creates a new layout that will format objecs as strings using the
17
+ # Creates a new layout that will format objects as strings using the
18
18
  # given <tt>:format_as</tt> style. This can be one of <tt>:string</tt>,
19
19
  # <tt>:inspect</tt>, or <tt>:yaml</tt>. These formatting commands map to
20
20
  # the following object methods:
@@ -52,7 +52,7 @@ class Layout
52
52
  # call-seq:
53
53
  # format( event )
54
54
  #
55
- # Returns a string representation of the given loggging _event_. It is
55
+ # Returns a string representation of the given logging _event_. It is
56
56
  # up to subclasses to implement this method.
57
57
  #
58
58
  def format( event ) nil end
@@ -70,19 +70,19 @@ class Layout
70
70
  #
71
71
  # Returns a footer string to be used at the end of a logging appender.
72
72
  #
73
- def footer( ) '' end
73
+ def footer( ) '' end
74
74
 
75
75
  # call-seq:
76
76
  # format_obj( obj )
77
77
  #
78
78
  # Return a string representation of the given object. Depending upon
79
79
  # the configuration of the logger system the format will be an +inspect+
80
- # based represenation or a +yaml+ based representation.
80
+ # based representation or a +yaml+ based representation.
81
81
  #
82
82
  def format_obj( obj )
83
83
  case obj
84
84
  when String; obj
85
- when Exception
85
+ when Exception
86
86
  str = "<#{obj.class.name}> #{obj.message}"
87
87
  if @backtrace && !obj.backtrace.nil?
88
88
  str << "\n\t" << obj.backtrace.join("\n\t")
@@ -114,4 +114,3 @@ class Layout
114
114
  end # class Layout
115
115
  end # module Logging
116
116
 
117
- # EOF
@@ -44,4 +44,3 @@ Logging.libpath {
44
44
  require 'logging/layouts/pattern'
45
45
  }
46
46
 
47
- # EOF
@@ -17,7 +17,7 @@ module Logging::Layouts
17
17
  # call-seq:
18
18
  # format( event )
19
19
  #
20
- # Returns a string representation of the given loggging _event_. See the
20
+ # Returns a string representation of the given logging _event_. See the
21
21
  # class documentation for details about the formatting used.
22
22
  #
23
23
  def format( event )
@@ -58,10 +58,10 @@ module Logging::Layouts
58
58
  #
59
59
  # The output order of the fields is not guaranteed to be the same as the
60
60
  # order specified in the _items_ list. This is because Ruby hashes are not
61
- # ordered by default (unless your running this in Ruby 1.9).
61
+ # ordered by default (unless you're running this in Ruby 1.9).
62
62
  #
63
63
  # When configured to output log events in JSON format, each log message
64
- # will be formatted as an object (in the JSON sense of the work) on it's
64
+ # will be formatted as an object (in the JSON sense of the word) on it's
65
65
  # own line in the log output. Therefore, to parse the output you must read
66
66
  # it line by line and parse the individual objects. Taking the same
67
67
  # example above the JSON output would be:
@@ -78,7 +78,7 @@ module Logging::Layouts
78
78
  # Arguments to sprintf keyed to directive letters
79
79
  DIRECTIVE_TABLE = {
80
80
  'logger' => 'event.logger',
81
- 'timestamp' => 'event.time.strftime(Pattern::ISO8601)',
81
+ 'timestamp' => 'event.time',
82
82
  'level' => '::Logging::LNAMES[event.level]',
83
83
  'message' => 'format_obj(event.data)',
84
84
  'file' => 'event.file',
@@ -132,7 +132,7 @@ module Logging::Layouts
132
132
  # call-seq:
133
133
  # Parseable.json( opts )
134
134
  #
135
- # Create a new Parseable layout that outputs log events usig JSON style
135
+ # Create a new Parseable layout that outputs log events using JSON style
136
136
  # formatting. See the initializer documentation for available options.
137
137
  #
138
138
  def self.json( opts = {} )
@@ -143,7 +143,7 @@ module Logging::Layouts
143
143
  # call-seq:
144
144
  # Parseable.yaml( opts )
145
145
  #
146
- # Create a new Parseable layout that outputs log events usig YAML style
146
+ # Create a new Parseable layout that outputs log events using YAML style
147
147
  # formatting. See the initializer documentation for available options.
148
148
  #
149
149
  def self.yaml( opts = {} )
@@ -191,7 +191,8 @@ module Logging::Layouts
191
191
  case value
192
192
  when String, Integer, Float; value.inspect
193
193
  when nil; 'null'
194
- else value.to_s.inspect end
194
+ when Time; %Q{"#{iso8601_format(value)}"}
195
+ else %Q{"#{value.inspect}"} end
195
196
  end
196
197
 
197
198
  # Call the appropriate class level create format method based on the
@@ -204,6 +205,19 @@ module Logging::Layouts
204
205
  else raise ArgumentError, "unknown format style '#@style'" end
205
206
  end
206
207
 
208
+ # Convert the given time _value_ into an ISO8601 formatted time string.
209
+ #
210
+ def iso8601_format( value )
211
+ str = value.strftime('%Y-%m-%dT%H:%M:%S')
212
+ str << ('.%06d' % value.usec)
213
+
214
+ offset = value.gmt_offset.abs
215
+ return str << 'Z' if offset == 0
216
+
217
+ offset = sprintf('%02d:%02d', offset / 3600, offset % 3600 / 60)
218
+ return str << (value.gmt_offset < 0 ? '-' : '+') << offset
219
+ end
220
+
207
221
  end # Parseable
208
222
  end # Logging::Layouts
209
223
 
@@ -13,7 +13,7 @@ module Logging
13
13
  # * $3 == method name (might be nil)
14
14
  CALLER_RGXP = %r/([-\.\/\(\)\w]+):(\d+)(?::in `(\w+)')?/o
15
15
  #CALLER_INDEX = 2
16
- CALLER_INDEX = (defined? JRUBY_VERSION and JRUBY_VERSION[%r/^1.6/]) ? 1 : 2
16
+ CALLER_INDEX = ((defined? JRUBY_VERSION and JRUBY_VERSION[%r/^1.6/]) or (defined? RUBY_ENGINE and RUBY_ENGINE[%r/^rbx/i])) ? 1 : 2
17
17
  # :startdoc:
18
18
 
19
19
  # call-seq:
@@ -209,7 +209,7 @@ module Logging
209
209
  # This method returns +true+ if the message was logged, and +false+ is
210
210
  # returned if the message was not logged.
211
211
  #
212
- def add( lvl, data = nil )
212
+ def add( lvl, data = nil, progname = nil )
213
213
  lvl = Integer(lvl)
214
214
  return false if lvl < level
215
215
 
@@ -280,7 +280,7 @@ module Logging
280
280
  # log.level = 'off'
281
281
  # log.level = :all
282
282
  #
283
- # These prodcue an +ArgumentError+
283
+ # These produce an +ArgumentError+
284
284
  #
285
285
  # log.level = Object
286
286
  # log.level = -1
data/lib/logging/proxy.rb CHANGED
@@ -17,7 +17,7 @@ module Logging
17
17
  # result # <-- always return the result
18
18
  # end
19
19
  #
20
- # The proxied object is avaiable as the "@object" variable. The logger is
20
+ # The proxied object is available as the "@object" variable. The logger is
21
21
  # available as the "@logger" variable.
22
22
  #
23
23
  class Proxy
@@ -30,7 +30,7 @@ module Logging
30
30
 
31
31
  # Create a new proxy for the given _object_. If an optional _block_ is
32
32
  # given it will be called before the proxied method. This _block_ will
33
- # replace the +method_missing+ implementation
33
+ # replace the +method_missing+ implementation
34
34
  #
35
35
  def initialize( object, &block )
36
36
  @object = object
@@ -14,7 +14,7 @@ module Logging
14
14
 
15
15
  # A no-op implementation of the +silence+ method. Setting of log levels
16
16
  # should be done during the Logging configuration. It is the author's
17
- # opinion that overriding the log level programmaticaly is a logical
17
+ # opinion that overriding the log level programmatically is a logical
18
18
  # error.
19
19
  #
20
20
  # Please see https://github.com/TwP/logging/issues/11 for a more detail
@@ -185,7 +185,7 @@ module Logging
185
185
  # call-seq:
186
186
  # master_for( key )
187
187
  #
188
- # Retruns the consolidation master name for the given _key_. If there is
188
+ # Returns the consolidation master name for the given _key_. If there is
189
189
  # no consolidation master, then +nil+ is returned.
190
190
  #
191
191
  def master_for( key )
@@ -229,4 +229,3 @@ module Logging
229
229
  end # class Repository
230
230
  end # module Logging
231
231
 
232
- # EOF
@@ -3,7 +3,7 @@ module Logging
3
3
 
4
4
  # The root logger exists to ensure that all loggers have a parent and a
5
5
  # defined logging level. If a logger is additive, eventually its log
6
- # events will propogate up to the root logger.
6
+ # events will propagate up to the root logger.
7
7
  #
8
8
  class RootLogger < Logger
9
9
 
@@ -58,4 +58,3 @@ module Logging
58
58
  end # class RootLogger
59
59
  end # module Logging
60
60
 
61
- # EOF
data/lib/logging/stats.rb CHANGED
@@ -40,7 +40,7 @@ module Logging::Stats
40
40
  # Coalesce the statistics from the _other_ sampler into this one. The
41
41
  # _other_ sampler is not modified by this method.
42
42
  #
43
- # Coalescing the same two samplers mutliple times should only be done if
43
+ # Coalescing the same two samplers multiple times should only be done if
44
44
  # one of the samplers is reset between calls to this method. Otherwise
45
45
  # statistics will be counted multiple times.
46
46
  #
@@ -72,7 +72,7 @@ module Logging::Stats
72
72
 
73
73
  # Returns statistics in a common format.
74
74
  #
75
- def to_s
75
+ def to_s
76
76
  "[%s]: SUM=%0.6f, SUMSQ=%0.6f, NUM=%d, MEAN=%0.6f, SD=%0.6f, MIN=%0.6f, MAX=%0.6f" % to_a
77
77
  end
78
78
 
@@ -127,7 +127,7 @@ module Logging::Stats
127
127
 
128
128
  # Adds a time delta between now and the last time you called this. This
129
129
  # will give you the average time between two activities.
130
- #
130
+ #
131
131
  # An example is:
132
132
  #
133
133
  # t = Sampler.new("do_stuff")
@@ -148,7 +148,7 @@ module Logging::Stats
148
148
 
149
149
  attr_reader :stats
150
150
 
151
- # Create a new Tracker instance. An optional boolean can be bassed in to
151
+ # Create a new Tracker instance. An optional boolean can be passed in to
152
152
  # change the "threadsafe" value of the tracker. By default all trackers
153
153
  # are created to be threadsafe.
154
154
  #
@@ -163,7 +163,7 @@ module Logging::Stats
163
163
  # Coalesce the samplers from the _other_ tracker into this one. The
164
164
  # _other_ tracker is not modified by this method.
165
165
  #
166
- # Coalescing the same two trackers mutliple times should only be done if
166
+ # Coalescing the same two trackers multiple times should only be done if
167
167
  # one of the trackers is reset between calls to this method. Otherwise
168
168
  # statistics will be counted multiple times.
169
169
  #
@@ -275,4 +275,3 @@ module Logging::Stats
275
275
 
276
276
  end # module Logging::Stats
277
277
 
278
- # EOF
data/lib/logging/utils.rb CHANGED
@@ -19,7 +19,7 @@ class Hash
19
19
  # String
20
20
  # Symbol
21
21
  #
22
- # If the value is +nil+, then no converstion will be performed.
22
+ # If the value is +nil+, then no conversion will be performed.
23
23
  #
24
24
  def getopt( *args )
25
25
  opts = args.last.instance_of?(Hash) ? args.pop : {}
@@ -4,7 +4,7 @@ module RSpec
4
4
 
5
5
  # Capture log messages from the Logging framework and make them
6
6
  # available via a @log_output instance variable. The @log_output
7
- # supports a readline method to access the log messags.
7
+ # supports a readline method to access the log messages.
8
8
  #
9
9
  def capture_log_messages( opts = {} )
10
10
  from = opts.getopt(:from, 'root')
@@ -14,9 +14,9 @@ module TestAppenders
14
14
  super
15
15
  Logging.init
16
16
  @levels = Logging::LEVELS
17
- @logopt = defined?(::Syslog::LOG_NDELAY) ?
18
- (::Syslog::LOG_PERROR | ::Syslog::LOG_NDELAY) :
19
- (::Syslog::LOG_PERROR)
17
+ @logopt = 0
18
+ @logopt |= ::Syslog::LOG_NDELAY if defined?(::Syslog::LOG_NDELAY)
19
+ @logopt |= ::Syslog::LOG_PERROR if defined?(::Syslog::LOG_PERROR)
20
20
  end
21
21
 
22
22
  def test_append
@@ -51,12 +51,14 @@ module TestAppenders
51
51
  stderr[1].close
52
52
  Process.waitpid(pid)
53
53
 
54
- assert_equal("syslog_test: INFO TestLogger : <Array> #{[1,2,3,4]}\n",
55
- stderr[0].gets)
56
- assert_equal("syslog_test: DEBUG TestLogger : the big log message\n",
57
- stderr[0].gets)
58
- assert_equal("syslog_test: WARN TestLogger : this is your last warning\n",
59
- stderr[0].gets)
54
+ if defined?(::Syslog::LOG_PERROR)
55
+ assert_equal("syslog_test: INFO TestLogger : <Array> #{[1,2,3,4]}\n",
56
+ stderr[0].gets)
57
+ assert_equal("syslog_test: DEBUG TestLogger : the big log message\n",
58
+ stderr[0].gets)
59
+ assert_equal("syslog_test: WARN TestLogger : this is your last warning\n",
60
+ stderr[0].gets)
61
+ end
60
62
  end
61
63
 
62
64
  def test_append_error
@@ -98,9 +100,11 @@ module TestAppenders
98
100
  stderr[1].close
99
101
  Process.waitpid(pid)
100
102
 
101
- assert_equal("syslog_test: this is a test message\n", stderr[0].gets)
102
- assert_equal("syslog_test: this is another message\n", stderr[0].gets)
103
- assert_equal("syslog_test: some other line\n", stderr[0].gets)
103
+ if defined?(::Syslog::LOG_PERROR)
104
+ assert_equal("syslog_test: this is a test message\n", stderr[0].gets)
105
+ assert_equal("syslog_test: this is another message\n", stderr[0].gets)
106
+ assert_equal("syslog_test: some other line\n", stderr[0].gets)
107
+ end
104
108
  end
105
109
 
106
110
  def test_concat_error
@@ -11,7 +11,7 @@ module TestLayouts
11
11
  super
12
12
  @layout = Logging.layouts.json({})
13
13
  @levels = Logging::LEVELS
14
- @date_fmt = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
14
+ @date_fmt = '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}(Z|[+-]\d{2}:\d{2})'
15
15
  Thread.current[:name] = nil
16
16
  end
17
17
 
@@ -11,7 +11,7 @@ module TestLayouts
11
11
  super
12
12
  @layout = Logging.layouts.yaml({})
13
13
  @levels = Logging::LEVELS
14
- @date_fmt = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
14
+ @date_fmt = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6,9} (Z|[+-]\d{2}:\d{2})'
15
15
  Thread.current[:name] = nil
16
16
  end
17
17
 
@@ -55,7 +55,7 @@ module TestLayouts
55
55
 
56
56
  @layout.items = %w[timestamp]
57
57
  assert_equal %w[timestamp], @layout.items
58
- assert_match %r/--- \ntimestamp: #@date_fmt\n/, @layout.format(event)
58
+ assert_match %r/\A--- ?\ntimestamp: '?#@date_fmt'?\n/, @layout.format(event)
59
59
 
60
60
  # 'foo' is not a recognized item
61
61
  assert_raise(ArgumentError) {
@@ -71,36 +71,36 @@ module TestLayouts
71
71
  event.method = 'method_name'
72
72
 
73
73
  @layout.items = %w[logger]
74
- assert_equal %Q[--- \nlogger: TestLogger\n], @layout.format(event)
74
+ assert_match %r/\A--- ?\nlogger: TestLogger\n/, @layout.format(event)
75
75
 
76
76
  @layout.items = %w[file]
77
- assert_equal %Q[--- \nfile: test_file.rb\n], @layout.format(event)
77
+ assert_match %r/\A--- ?\nfile: test_file.rb\n/, @layout.format(event)
78
78
 
79
79
  @layout.items = %w[level]
80
- assert_equal %Q[--- \nlevel: INFO\n], @layout.format(event)
80
+ assert_match %r/\A--- ?\nlevel: INFO\n/, @layout.format(event)
81
81
 
82
82
  @layout.items = %w[line]
83
- assert_equal %Q[--- \nline: 123\n], @layout.format(event)
83
+ assert_match %r/\A--- ?\nline: 123\n/, @layout.format(event)
84
84
 
85
85
  @layout.items = %w[message]
86
- assert_equal %Q[--- \nmessage: log message\n], @layout.format(event)
86
+ assert_match %r/\A--- ?\nmessage: log message\n/, @layout.format(event)
87
87
 
88
88
  @layout.items = %w[method]
89
- assert_equal %Q[--- \nmethod: method_name\n], @layout.format(event)
89
+ assert_match %r/\A--- ?\nmethod: method_name\n/, @layout.format(event)
90
90
 
91
91
  @layout.items = %w[pid]
92
- assert_match %r/\A--- \npid: \d+\n\z/, @layout.format(event)
92
+ assert_match %r/\A--- ?\npid: \d+\n\z/, @layout.format(event)
93
93
 
94
94
  @layout.items = %w[millis]
95
- assert_match %r/\A--- \nmillis: \d+\n\z/, @layout.format(event)
95
+ assert_match %r/\A--- ?\nmillis: \d+\n\z/, @layout.format(event)
96
96
 
97
97
  @layout.items = %w[thread_id]
98
- assert_match %r/\A--- \nthread_id: -?\d+\n\z/, @layout.format(event)
98
+ assert_match %r/\A--- ?\nthread_id: -?\d+\n\z/, @layout.format(event)
99
99
 
100
100
  @layout.items = %w[thread]
101
- assert_equal %Q[--- \nthread: \n], @layout.format(event)
101
+ assert_match %r/\A--- ?\nthread: \n/, @layout.format(event)
102
102
  Thread.current[:name] = "Main"
103
- assert_equal %Q[--- \nthread: Main\n], @layout.format(event)
103
+ assert_match %r/\A--- ?\nthread: Main\n/, @layout.format(event)
104
104
  end
105
105
 
106
106
  private
@@ -108,7 +108,7 @@ module TestLayouts
108
108
  def assert_yaml_match( expected, actual )
109
109
  actual = YAML.load(actual)
110
110
 
111
- assert_match %r/#@date_fmt/o, actual['timestamp']
111
+ assert_instance_of Time, actual['timestamp']
112
112
  assert_equal expected['level'], actual['level']
113
113
  assert_equal expected['logger'], actual['logger']
114
114
  assert_equal expected['message'], actual['message']
data/test/test_layout.rb CHANGED
@@ -75,10 +75,14 @@ module TestLogging
75
75
 
76
76
  @layout = ::Logging::Layout.new :format_as => :yaml
77
77
  r = @layout.format_obj obj
78
- assert_equal "<Array> \n--- \n- one\n- two\n- three\n- four\n", r
79
-
78
+ assert_match %r/\A<Array> \n--- ?\n- one\n- two\n- three\n- four\n/, r
79
+
80
80
  r = @layout.format_obj Class
81
- assert_equal "<Class> Class", r
81
+ if defined? YAML::ENGINE and YAML::ENGINE.yamler == 'psych'
82
+ assert_equal "<Class> \n--- !ruby/class 'Class'\n", r
83
+ else
84
+ assert_equal "<Class> Class", r
85
+ end
82
86
  end
83
87
 
84
88
  def test_format_obj_without_backtrace
@@ -48,7 +48,7 @@ module TestLogging
48
48
 
49
49
  @logger.trace = true
50
50
  @logger.error 'error message'
51
- assert_equal 50, @appender.event.line
51
+ assert_equal __LINE__-1, @appender.event.line
52
52
  end
53
53
 
54
54
  def test_logger
data/version.txt CHANGED
@@ -1 +1 @@
1
- 1.6.1
1
+ 1.6.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-09 00:00:00.000000000Z
12
+ date: 2012-01-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: little-plugger
16
- requirement: &2162102160 !ruby/object:Gem::Requirement
16
+ requirement: &2157085220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.1.2
21
+ version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2162102160
24
+ version_requirements: *2157085220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: flexmock
27
- requirement: &2162101340 !ruby/object:Gem::Requirement
27
+ requirement: &2157077040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2162101340
35
+ version_requirements: *2157077040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bones-git
38
- requirement: &2162100820 !ruby/object:Gem::Requirement
38
+ requirement: &2157076220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2162100820
46
+ version_requirements: *2157076220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bones-rcov
49
- requirement: &2162100100 !ruby/object:Gem::Requirement
49
+ requirement: &2157075340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,18 +54,18 @@ dependencies:
54
54
  version: 1.0.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2162100100
57
+ version_requirements: *2157075340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bones
60
- requirement: &2162099500 !ruby/object:Gem::Requirement
60
+ requirement: &2157074540 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 3.7.0
65
+ version: 3.7.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2162099500
68
+ version_requirements: *2157074540
69
69
  description: ! 'Logging is a flexible logging library for use in Ruby programs based
70
70
  on the
71
71
 
@@ -81,6 +81,8 @@ extra_rdoc_files:
81
81
  - History.txt
82
82
  - README.rdoc
83
83
  files:
84
+ - .gitignore
85
+ - .rvmrc
84
86
  - History.txt
85
87
  - README.rdoc
86
88
  - Rakefile
@@ -184,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
186
  version: '0'
185
187
  requirements: []
186
188
  rubyforge_project: logging
187
- rubygems_version: 1.8.6
189
+ rubygems_version: 1.8.11
188
190
  signing_key:
189
191
  specification_version: 3
190
192
  summary: A flexible and extendable logging library for Ruby