vcap_logging 0.1.4
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/Gemfile +3 -0
- data/Rakefile +10 -0
- data/lib/vcap/logging/error.rb +5 -0
- data/lib/vcap/logging/formatter/base_formatter.rb +30 -0
- data/lib/vcap/logging/formatter/delimited_formatter.rb +96 -0
- data/lib/vcap/logging/formatter.rb +2 -0
- data/lib/vcap/logging/log_record.rb +71 -0
- data/lib/vcap/logging/logger.rb +116 -0
- data/lib/vcap/logging/sink/base_sink.rb +83 -0
- data/lib/vcap/logging/sink/file_sink.rb +120 -0
- data/lib/vcap/logging/sink/stdio_sink.rb +25 -0
- data/lib/vcap/logging/sink/string_sink.rb +18 -0
- data/lib/vcap/logging/sink/syslog_sink.rb +67 -0
- data/lib/vcap/logging/sink.rb +5 -0
- data/lib/vcap/logging/sink_map.rb +62 -0
- data/lib/vcap/logging/version.rb +5 -0
- data/lib/vcap/logging.rb +160 -0
- data/spec/Rakefile +15 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/base_sink_spec.rb +38 -0
- data/spec/unit/delimited_formatter_spec.rb +44 -0
- data/spec/unit/file_sink_spec.rb +79 -0
- data/spec/unit/log_record_spec.rb +51 -0
- data/spec/unit/logger_spec.rb +148 -0
- data/spec/unit/logging_spec.rb +114 -0
- data/spec/unit/sink_map_spec.rb +64 -0
- data/spec/unit/stdio_sink_spec.rb +20 -0
- data/spec/unit/string_sink_spec.rb +13 -0
- data/spec/unit/syslog_sink_spec.rb +23 -0
- metadata +112 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe VCAP::Logging::Sink::StdioSink do
|
4
|
+
it 'should not close the underlying io object when closed' do
|
5
|
+
io = mock(:stdout)
|
6
|
+
io.should_not_receive(:close)
|
7
|
+
sink = VCAP::Logging::Sink::StdioSink.new(io)
|
8
|
+
sink.close
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should write formatted messages to the underlying io device' do
|
12
|
+
msg = 'test log message'
|
13
|
+
fmt = mock(:formatter)
|
14
|
+
fmt.should_receive(:format_record).with(nil).and_return(msg)
|
15
|
+
io = mock(:stdio)
|
16
|
+
io.should_receive(:write).with(msg)
|
17
|
+
sink = VCAP::Logging::Sink::StdioSink.new(io, fmt)
|
18
|
+
sink.add_record(nil)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe VCAP::Logging::Sink::StringSink do
|
4
|
+
it 'should append formatted messages to the given string' do
|
5
|
+
msg = 'test log message'
|
6
|
+
fmt = mock(:formatter)
|
7
|
+
fmt.should_receive(:format_record).with(nil).and_return(msg)
|
8
|
+
str = mock(:str)
|
9
|
+
str.should_receive(:<<).with(msg)
|
10
|
+
sink = VCAP::Logging::Sink::StringSink.new(str, fmt)
|
11
|
+
sink.add_record(nil)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
require 'syslog'
|
4
|
+
|
5
|
+
describe VCAP::Logging::Sink::SyslogSink do
|
6
|
+
it 'should use the user facility for logging messages' do
|
7
|
+
Syslog.should_receive(:open).with('test', Syslog::LOG_PID, Syslog::LOG_USER).and_return(nil)
|
8
|
+
sink = VCAP::Logging::Sink::SyslogSink.new('test')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should map app log levels to syslog levels' do
|
12
|
+
msg = 'test message'
|
13
|
+
rec = mock(:test_record)
|
14
|
+
rec.should_receive(:log_level).and_return(:info)
|
15
|
+
fmt = mock(:test_formatter)
|
16
|
+
fmt.should_receive(:format_record).with(any_args()).and_return(msg)
|
17
|
+
Syslog.should_receive(:open).with('test', Syslog::LOG_PID, Syslog::LOG_USER).and_return(Syslog)
|
18
|
+
Syslog.should_receive(:log).with(Syslog::LOG_INFO, '%s', msg).and_return(nil)
|
19
|
+
sink = VCAP::Logging::Sink::SyslogSink.new('test')
|
20
|
+
sink.formatter = fmt
|
21
|
+
sink.add_record(rec)
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vcap_logging
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.4
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- mpage
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-02-03 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
description: This provides a minimal logging gem to be used across CF components
|
39
|
+
email:
|
40
|
+
- mpage@vmware.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- Rakefile
|
49
|
+
- Gemfile
|
50
|
+
- lib/vcap/logging/error.rb
|
51
|
+
- lib/vcap/logging/formatter/base_formatter.rb
|
52
|
+
- lib/vcap/logging/formatter/delimited_formatter.rb
|
53
|
+
- lib/vcap/logging/formatter.rb
|
54
|
+
- lib/vcap/logging/log_record.rb
|
55
|
+
- lib/vcap/logging/logger.rb
|
56
|
+
- lib/vcap/logging/sink/base_sink.rb
|
57
|
+
- lib/vcap/logging/sink/file_sink.rb
|
58
|
+
- lib/vcap/logging/sink/stdio_sink.rb
|
59
|
+
- lib/vcap/logging/sink/string_sink.rb
|
60
|
+
- lib/vcap/logging/sink/syslog_sink.rb
|
61
|
+
- lib/vcap/logging/sink.rb
|
62
|
+
- lib/vcap/logging/sink_map.rb
|
63
|
+
- lib/vcap/logging/version.rb
|
64
|
+
- lib/vcap/logging.rb
|
65
|
+
- spec/Rakefile
|
66
|
+
- spec/spec_helper.rb
|
67
|
+
- spec/unit/base_sink_spec.rb
|
68
|
+
- spec/unit/delimited_formatter_spec.rb
|
69
|
+
- spec/unit/file_sink_spec.rb
|
70
|
+
- spec/unit/log_record_spec.rb
|
71
|
+
- spec/unit/logger_spec.rb
|
72
|
+
- spec/unit/logging_spec.rb
|
73
|
+
- spec/unit/sink_map_spec.rb
|
74
|
+
- spec/unit/stdio_sink_spec.rb
|
75
|
+
- spec/unit/string_sink_spec.rb
|
76
|
+
- spec/unit/syslog_sink_spec.rb
|
77
|
+
has_rdoc: true
|
78
|
+
homepage: http://www.cloudfoundry.com
|
79
|
+
licenses: []
|
80
|
+
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: -3280320916878742029
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: -3280320916878742029
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.6.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Minimal logging gem used for CF components
|
111
|
+
test_files: []
|
112
|
+
|