formatted_rails_logger 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,11 +6,20 @@ class FormattedRailsLogger::Formatter
|
|
6
6
|
# or the Severity twice.
|
7
7
|
@@format_str = "[%s] %5s %s"
|
8
8
|
@@datetime_format = nil
|
9
|
-
|
10
|
-
def call(severity, time, progname, msg)
|
9
|
+
|
10
|
+
def call(severity, time, progname, msg)
|
11
|
+
msg = "" if msg.nil? # need to manipulate it as string
|
12
|
+
|
11
13
|
# Rails 3.2 seems to automatically add a newline, for consistency
|
12
14
|
# we will too.
|
13
|
-
msg += "\n"
|
15
|
+
msg += "\n"
|
16
|
+
|
17
|
+
# if the msg is blank, meant to create a newline, then
|
18
|
+
# just output it without any preliminaries, to keep the
|
19
|
+
# newline as seperator. Also return quick for nil msg, to
|
20
|
+
# avoid causing problems with later logic.
|
21
|
+
return msg if msg.blank?
|
22
|
+
|
14
23
|
|
15
24
|
# see no need for micro-seconds like in Logger, milis suffices.
|
16
25
|
# No idea why documented %L and other such useful things
|
@@ -20,14 +29,15 @@ class FormattedRailsLogger::Formatter
|
|
20
29
|
else
|
21
30
|
time.strftime("%Y-%m-%d %H:%M:%S.") << time.usec.to_s[0..2].rjust(3)
|
22
31
|
end
|
23
|
-
|
32
|
+
|
24
33
|
# Rails likes to log with some preceding newlines for spacing in the
|
25
34
|
# logfile. We want to preserve those when present,
|
26
35
|
# but prefix actual content with our prefix.
|
27
|
-
|
28
|
-
|
36
|
+
matchData = ( /\A(\n*)/.match(msg) )
|
37
|
+
|
38
|
+
|
29
39
|
matchData[0] + (@@format_str % [formatted_time, severity, matchData.post_match])
|
30
|
-
end
|
31
|
-
|
40
|
+
end
|
41
|
+
|
32
42
|
end
|
33
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatted_rails_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 3.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.0
|
25
30
|
description:
|
26
31
|
email:
|
27
32
|
- jonathan@dnil.net
|
@@ -50,15 +55,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
55
|
- - ! '>='
|
51
56
|
- !ruby/object:Gem::Version
|
52
57
|
version: '0'
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
hash: -15925174849965092
|
53
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
62
|
none: false
|
55
63
|
requirements:
|
56
64
|
- - ! '>='
|
57
65
|
- !ruby/object:Gem::Version
|
58
66
|
version: '0'
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
hash: -15925174849965092
|
59
70
|
requirements: []
|
60
71
|
rubyforge_project: formatted_rails_logger
|
61
|
-
rubygems_version: 1.8.
|
72
|
+
rubygems_version: 1.8.24
|
62
73
|
signing_key:
|
63
74
|
specification_version: 3
|
64
75
|
summary: Formatting capabilities for Rails BufferedLogger
|