logging 1.1.1 → 1.1.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/History.txt +5 -0
- data/lib/logging.rb +7 -17
- data/lib/logging/appenders/rolling_file.rb +1 -1
- data/lib/logging/utils.rb +77 -0
- metadata +2 -2
data/History.txt
CHANGED
data/lib/logging.rb
CHANGED
@@ -3,25 +3,17 @@
|
|
3
3
|
# Used to prevent the class/module from being loaded more than once
|
4
4
|
unless defined? Logging
|
5
5
|
|
6
|
+
require File.expand_path(
|
7
|
+
File.join(File.dirname(__FILE__), %w[logging utils]))
|
8
|
+
|
6
9
|
require 'yaml'
|
7
10
|
require 'stringio'
|
8
11
|
require 'thread'
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
retry if require 'rubygems'
|
14
|
-
raise
|
15
|
-
end
|
16
|
-
|
17
|
-
begin
|
18
|
-
require 'syslog'
|
19
|
-
HAVE_SYSLOG = true
|
20
|
-
rescue LoadError
|
21
|
-
HAVE_SYSLOG = false
|
22
|
-
end
|
13
|
+
HAVE_LOCKFILE = require? 'lockfile'
|
14
|
+
HAVE_SYSLOG = require? 'syslog'
|
15
|
+
require? 'fastthread'
|
23
16
|
|
24
|
-
begin require 'fastthread'; rescue LoadError; end
|
25
17
|
|
26
18
|
# TODO: Windows Log Service appender
|
27
19
|
|
@@ -30,10 +22,9 @@ begin require 'fastthread'; rescue LoadError; end
|
|
30
22
|
module Logging
|
31
23
|
|
32
24
|
# :stopdoc:
|
33
|
-
VERSION = '1.1.
|
25
|
+
VERSION = '1.1.2'
|
34
26
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
35
27
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
36
|
-
WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM
|
37
28
|
LEVELS = {}
|
38
29
|
LNAMES = []
|
39
30
|
# :startdoc:
|
@@ -466,7 +457,6 @@ module Logging
|
|
466
457
|
end # module Logging
|
467
458
|
|
468
459
|
|
469
|
-
require Logging.libpath(%w[logging utils])
|
470
460
|
require Logging.libpath(%w[logging appender])
|
471
461
|
require Logging.libpath(%w[logging layout])
|
472
462
|
require Logging.libpath(%w[logging log_event])
|
@@ -71,7 +71,7 @@ module Logging::Appenders
|
|
71
71
|
@keep = opts.getopt(:keep, :as => Integer)
|
72
72
|
@size = opts.getopt(:size, :as => Integer)
|
73
73
|
|
74
|
-
@lockfile = if opts.getopt(:safe, false)
|
74
|
+
@lockfile = if HAVE_LOCKFILE and opts.getopt(:safe, false)
|
75
75
|
::Lockfile.new(
|
76
76
|
@fn + '.lck',
|
77
77
|
:retries => 1,
|
data/lib/logging/utils.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
# --------------------------------------------------------------------------
|
2
3
|
class Hash
|
3
4
|
|
4
5
|
# call-seq:
|
@@ -40,6 +41,7 @@ class Hash
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
# --------------------------------------------------------------------------
|
43
45
|
class String
|
44
46
|
|
45
47
|
# call-seq:
|
@@ -69,6 +71,7 @@ class String
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
74
|
+
# --------------------------------------------------------------------------
|
72
75
|
class Module
|
73
76
|
|
74
77
|
# call-seq:
|
@@ -102,6 +105,80 @@ class Module
|
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
108
|
+
# --------------------------------------------------------------------------
|
109
|
+
module Kernel
|
110
|
+
|
111
|
+
# Settiing this global variable to +false+ will disable rubygems from
|
112
|
+
# being loaded at all.
|
113
|
+
$use_rubygems = true unless defined? $use_rubygems
|
114
|
+
|
115
|
+
# Setting this global variable to +true+ will cause an error message to be
|
116
|
+
# displayed when a library cannot be required.
|
117
|
+
$whiny_require = false unless defined? $whiny_require
|
118
|
+
|
119
|
+
# call-seq:
|
120
|
+
# require!( string )
|
121
|
+
# require!( string, gem_version )
|
122
|
+
# require!( string, gem_name, gem_version )
|
123
|
+
#
|
124
|
+
# Attempt to the load the library named _string_ using the standard
|
125
|
+
# Kernel#require method. If the library cannot be loaded then require
|
126
|
+
# rubygems and retry the original require of the library.
|
127
|
+
#
|
128
|
+
# Raises a LoadError if the library cannot be loaded.
|
129
|
+
#
|
130
|
+
# If a _gem_version_ is given, then the rubygems +gem+ command is used to
|
131
|
+
# load the specific version of the gem. The library _string_ is used for
|
132
|
+
# the _gem_name_ if one is omitted.
|
133
|
+
#
|
134
|
+
def require!( string, *args )
|
135
|
+
return require(string) if args.empty?
|
136
|
+
|
137
|
+
name, version = *args
|
138
|
+
version, name = name, string if name =~ %r/^[0-9<>=~]/
|
139
|
+
version ||= '> 0'
|
140
|
+
|
141
|
+
gem name, version
|
142
|
+
require(string)
|
143
|
+
rescue LoadError, NoMethodError
|
144
|
+
retry if $use_rubygems and require('rubygems')
|
145
|
+
if $whiny_require
|
146
|
+
name ||= string
|
147
|
+
$stderr.puts "Required library #{string.inspect} could not be loaded."
|
148
|
+
$stderr.puts "Try:\tgem install #{name}"
|
149
|
+
end
|
150
|
+
raise
|
151
|
+
end
|
152
|
+
|
153
|
+
# call-seq:
|
154
|
+
# require?( string )
|
155
|
+
# require?( string, gem_version )
|
156
|
+
# require?( string, gem_name, gem_version )
|
157
|
+
#
|
158
|
+
# Attempt to the load the library named _string_ using the standard
|
159
|
+
# Kernel#require method. If the library cannot be loaded then require
|
160
|
+
# rubygems and retry the original require of the library.
|
161
|
+
#
|
162
|
+
# Returns +true+ if the library was successfully loaded. Returns +false+
|
163
|
+
# if the library could not be loaded. This method will never raise an
|
164
|
+
# exception.
|
165
|
+
#
|
166
|
+
# If a _gem_version_ is given, then the rubygems +gem+ command is used to
|
167
|
+
# load the specific version of the gem. The library _string_ is used for
|
168
|
+
# the _gem_name_ if one is omitted.
|
169
|
+
#
|
170
|
+
def require?( string, *args )
|
171
|
+
wr, $whiny_require = $whiny_require, false
|
172
|
+
require!(string, *args)
|
173
|
+
return true
|
174
|
+
rescue LoadError
|
175
|
+
return false
|
176
|
+
ensure
|
177
|
+
$whiny_require = wr
|
178
|
+
end
|
179
|
+
end # module Kernel
|
180
|
+
|
181
|
+
# --------------------------------------------------------------------------
|
105
182
|
class ReentrantMutex < Mutex
|
106
183
|
|
107
184
|
def initialize
|
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.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-05 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|