catamaran 2.5.0 → 2.6.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.
- checksums.yaml +15 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +2 -1
- data/Rakefile +5 -0
- data/catamaran.gemspec +3 -0
- data/examples/quickstart_with_ruby.rb +3 -0
- data/lib/catamaran/formatter.rb +28 -4
- data/lib/catamaran/manager.rb +5 -1
- data/lib/catamaran/version.rb +1 -1
- data/spec/formatter_spec.rb +3 -3
- data/spec/manager_spec.rb +5 -3
- metadata +54 -34
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
NmE5NjZmNDg0NmZjNTUxYmY5NmM0NDBiYWU0YTY3ZTgwNTk3Y2FjYQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
NTg0ZTQ2ZThkMWIzY2NkOTMwYmQwOWQ1ZDUxNmE0ZDU4ZWJlYThmMQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
YzAxNWEwNjU4Y2EyM2E1NGE4YmI1MmI4YzMxZGVhMDU5MDFlMWIxZDk0ZThk
|
|
10
|
+
YjdlNjU4NTM5YmJjMjMwNTJmZGExNTE0MjRhNTAyYmY5ZTA5ZDhlMmYyOGQz
|
|
11
|
+
ZjVjZDIyOTBhM2Y0ODQxYzZmYWUwZDdiNzhhNGE1YjgyOWQ5ZmQ=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
YzYyZTFkMWM4YTEwMjY5Yjk0ZTAyM2ZjZDYyOGJmNjg1YTMyYzcxNzdmNzUw
|
|
14
|
+
NWJmZjFlYzRjMTUyZDJkMWNmNTk4ZWE0YzNlMzlhMzE2ODIyMTVlZjU5YThl
|
|
15
|
+
NDRmMGM1ZDRiYzI3ZmY4YTU2NTc4NzgxMWYxNTQ4MTAyODdjZGY=
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Catamaran
|
|
2
2
|
=========
|
|
3
|
+
[](https://travis-ci.org/jgithub/catamaran)
|
|
3
4
|
|
|
4
5
|
Logging is a powerful and often undervalued tool in software development. When done right, it's a great way to document code, and it provides a simple & effective way to solve problems when things go awry. All an important part of maintainable code.
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ Catamaran was built around a named hierarchy and level inheritance, and with per
|
|
|
8
9
|
Gemfile
|
|
9
10
|
-------
|
|
10
11
|
|
|
11
|
-
gem 'catamaran', '~> 2.
|
|
12
|
+
gem 'catamaran', '~> 2.6.0'
|
|
12
13
|
|
|
13
14
|
Rails-related setup:
|
|
14
15
|
|
data/Rakefile
ADDED
data/catamaran.gemspec
CHANGED
|
@@ -52,6 +52,9 @@ class QuickstartWithRuby
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
|
|
56
|
+
# Catamaran::Manager.formatter_pattern = "%-6p pid-%pid [%d{ISO8601}] %47C - %m"
|
|
57
|
+
|
|
55
58
|
quickstart_with_ruby = QuickstartWithRuby.new
|
|
56
59
|
quickstart_with_ruby.demonstrating_log_levels
|
|
57
60
|
quickstart_with_ruby.using_the_caller
|
data/lib/catamaran/formatter.rb
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
1
3
|
module Catamaran
|
|
2
4
|
class Formatter
|
|
3
5
|
@@caller_enabled = false
|
|
4
6
|
|
|
5
7
|
FAVORITE_FORMATTER_PATTERNS = {
|
|
6
|
-
"%-6p pid-%pid [%d{
|
|
7
|
-
"%c pid-%P [%d] %p - %m" => 2
|
|
8
|
+
"%-6p pid-%pid [%d{ISO8601}] %47C - %m" => 1,
|
|
9
|
+
"%c pid-%P [%d] %p - %m" => 2,
|
|
10
|
+
|
|
11
|
+
"%-6p pid-%pid [%d{yyyy-MM-ddTHH:mm:ss.SSSZ}] %47C - %m" => 3,
|
|
12
|
+
"%-6p pid-%pid [%d{ISO8601Z}] %47C - %m" => 3,
|
|
13
|
+
|
|
14
|
+
"%-6p pid-%pid [%d{yyyy-MM-dd HH:mm:ss.SSS}] %47C - %m" => 4,
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
|
|
@@ -20,6 +27,10 @@ module Catamaran
|
|
|
20
27
|
full_msg = construct_favorite_pattern_number_1( severity, path, msg, opts )
|
|
21
28
|
elsif ( @favorite_pattern_number == 2 )
|
|
22
29
|
full_msg = construct_favorite_pattern_number_2( severity, path, msg, opts )
|
|
30
|
+
elsif ( @favorite_pattern_number == 3 )
|
|
31
|
+
full_msg = construct_favorite_pattern_number_3( severity, path, msg, opts )
|
|
32
|
+
elsif ( @favorite_pattern_number == 4 )
|
|
33
|
+
full_msg = construct_favorite_pattern_number_4( severity, path, msg, opts )
|
|
23
34
|
else
|
|
24
35
|
# A "favorite pattern" (better for performance) was not specified. Construct a custom message
|
|
25
36
|
full_msg = construct_custom_pattern( severity, path, msg, opts )
|
|
@@ -108,10 +119,10 @@ module Catamaran
|
|
|
108
119
|
protected
|
|
109
120
|
|
|
110
121
|
def self.construct_favorite_pattern_number_1( severity, path, msg, opts )
|
|
111
|
-
sprintf( "%6s pid-#{Process.pid} [#{
|
|
122
|
+
sprintf( "%6s pid-#{Process.pid} [#{DateTime.now.iso8601}] %47s - #{msg}",
|
|
112
123
|
LogLevel.severity_to_s( severity ),
|
|
113
124
|
( path.length > 47 ) ? path.dup[-47,47] : path )
|
|
114
|
-
end
|
|
125
|
+
end
|
|
115
126
|
|
|
116
127
|
def self.construct_favorite_pattern_number_2( severity, path, msg, opts )
|
|
117
128
|
sprintf( "%6s pid-#{Process.pid} [#{Time.now.to_s}] %s - #{msg}",
|
|
@@ -119,6 +130,19 @@ module Catamaran
|
|
|
119
130
|
path )
|
|
120
131
|
end
|
|
121
132
|
|
|
133
|
+
def self.construct_favorite_pattern_number_3( severity, path, msg, opts )
|
|
134
|
+
sprintf( "%6s pid-#{Process.pid} [#{Time.now.gmtime.strftime( "%Y-%m-%dT%H:%M:%S.%LZ" )}] %47s - #{msg}",
|
|
135
|
+
LogLevel.severity_to_s( severity ),
|
|
136
|
+
( path.length > 47 ) ? path.dup[-47,47] : path )
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def self.construct_favorite_pattern_number_4( severity, path, msg, opts )
|
|
140
|
+
sprintf( "%6s pid-#{Process.pid} [#{Time.now.strftime( "%Y-%m-%d %H:%M:%S:%L" )}] %47s - #{msg}",
|
|
141
|
+
LogLevel.severity_to_s( severity ),
|
|
142
|
+
( path.length > 47 ) ? path.dup[-47,47] : path )
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
|
|
122
146
|
def self.construct_custom_pattern( severity, path, msg, opts )
|
|
123
147
|
if opts && opts[:pattern]
|
|
124
148
|
full_msg = opts[:pattern].dup # dup may be extra work
|
data/lib/catamaran/manager.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Catamaran
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def self.formatter_pattern
|
|
32
|
-
@formatter_pattern ||= "%-6p pid-%pid [%d{
|
|
32
|
+
@formatter_pattern ||= "%-6p pid-%pid [%d{ISO8601}] %47C - %m"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def self.formatter_pattern=( value )
|
|
@@ -57,6 +57,10 @@ module Catamaran
|
|
|
57
57
|
|
|
58
58
|
Catamaran::Formatter.reset
|
|
59
59
|
|
|
60
|
+
if opts[:hard_reset]
|
|
61
|
+
@formatter_pattern = nil
|
|
62
|
+
end
|
|
63
|
+
|
|
60
64
|
# Resetting Catamaran probably should not reset the output settings
|
|
61
65
|
# self.send( :_stdout_flag=, nil )
|
|
62
66
|
# self.send( :_stderr_flag=, nil )
|
data/lib/catamaran/version.rb
CHANGED
data/spec/formatter_spec.rb
CHANGED
|
@@ -9,7 +9,7 @@ describe Catamaran::Formatter do
|
|
|
9
9
|
|
|
10
10
|
context "when using a custom format pattern" do
|
|
11
11
|
context "with no options" do
|
|
12
|
-
pattern
|
|
12
|
+
let(:pattern) { "%c (%d) %p PID: %P | %m" }
|
|
13
13
|
it "outputs the custom format" do
|
|
14
14
|
message = Catamaran::Formatter.construct_formatted_message( severity, path, log_message, :pattern => pattern)
|
|
15
15
|
message.should match /^\s+ERROR\s\(.*\)\s#{path}\sPID:\s\d+\s\|\s#{log_message}$/
|
|
@@ -17,7 +17,7 @@ describe Catamaran::Formatter do
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
context "when a custom format pattern is
|
|
20
|
+
context "when a custom format pattern is NOT specified" do
|
|
21
21
|
it "should make use of Manager.formatter_pattern" do
|
|
22
22
|
Catamaran::Manager::formatter_pattern = "%c pid-%P [%d] %p - %m"
|
|
23
23
|
message = Catamaran::Formatter.construct_formatted_message( severity, path, log_message, {} )
|
|
@@ -25,7 +25,7 @@ describe Catamaran::Formatter do
|
|
|
25
25
|
|
|
26
26
|
Catamaran::Manager.reset
|
|
27
27
|
|
|
28
|
-
Catamaran::Manager::formatter_pattern = "%-6p pid-%pid [%d{yyyy-
|
|
28
|
+
Catamaran::Manager::formatter_pattern = "%-6p pid-%pid [%d{yyyy-MM-dd HH:mm:ss.SSS}] %47C - %m"
|
|
29
29
|
message = Catamaran::Formatter.construct_formatted_message( severity, path, log_message, {} )
|
|
30
30
|
message.should match /^\s+ERROR\spid\-\d+\s\[.*\]\s\s\s\s\s\s\s\s\s\s\s+#{path}\s\-\s#{log_message}$/
|
|
31
31
|
end
|
data/spec/manager_spec.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Catamaran::Manager do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
context 'by default' do
|
|
5
|
+
describe ".formatter_pattern" do
|
|
6
|
+
it "should be of the format \"%-6p pid-%pid [%d{ISO8601}] %47C - %m\"" do
|
|
7
|
+
Catamaran::Manager.formatter_pattern.should == "%-6p pid-%pid [%d{ISO8601}] %47C - %m"
|
|
8
|
+
end
|
|
7
9
|
end
|
|
8
10
|
end
|
|
9
11
|
end
|
metadata
CHANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: catamaran
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.6.0
|
|
5
5
|
platform: ruby
|
|
6
|
-
authors:
|
|
6
|
+
authors:
|
|
7
7
|
- Jeano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ! '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ! '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ! '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ! '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
16
41
|
description: A logging utility
|
|
17
|
-
email:
|
|
42
|
+
email:
|
|
18
43
|
- catamaran@jeano.net
|
|
19
44
|
executables: []
|
|
20
|
-
|
|
21
45
|
extensions: []
|
|
22
|
-
|
|
23
46
|
extra_rdoc_files: []
|
|
24
|
-
|
|
25
|
-
files:
|
|
47
|
+
files:
|
|
26
48
|
- .gitignore
|
|
49
|
+
- .travis.yml
|
|
50
|
+
- Gemfile
|
|
27
51
|
- LICENSE
|
|
28
52
|
- README.md
|
|
53
|
+
- Rakefile
|
|
29
54
|
- catamaran.gemspec
|
|
30
55
|
- examples/benchmarking_conditional_log_statements.rb
|
|
31
56
|
- examples/benchmarking_the_caller.rb
|
|
@@ -53,33 +78,28 @@ files:
|
|
|
53
78
|
- spec/formatter_spec.rb
|
|
54
79
|
- spec/manager_spec.rb
|
|
55
80
|
- spec/spec_helper.rb
|
|
56
|
-
has_rdoc: true
|
|
57
81
|
homepage: http://github.com/jgithub/catamaran
|
|
58
|
-
licenses:
|
|
82
|
+
licenses:
|
|
59
83
|
- MIT
|
|
84
|
+
metadata: {}
|
|
60
85
|
post_install_message:
|
|
61
86
|
rdoc_options: []
|
|
62
|
-
|
|
63
|
-
require_paths:
|
|
87
|
+
require_paths:
|
|
64
88
|
- lib
|
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- -
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
version: "0"
|
|
76
|
-
version:
|
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
77
99
|
requirements: []
|
|
78
|
-
|
|
79
100
|
rubyforge_project:
|
|
80
|
-
rubygems_version:
|
|
101
|
+
rubygems_version: 2.2.1
|
|
81
102
|
signing_key:
|
|
82
|
-
specification_version:
|
|
103
|
+
specification_version: 4
|
|
83
104
|
summary: Catamaran Logger
|
|
84
105
|
test_files: []
|
|
85
|
-
|