steno 1.1.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODVjZjY5ZmYzYzM3NGFhMDlkMWYxYWM5MjAzYTI0MThlNzRiMTViOQ==
5
+ data.tar.gz: !binary |-
6
+ N2ZmNDRjYWVlNjE0ODk0YTk5NTI5NGM1ZTU4MDk5NWZjNmE5Y2UzYg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZGZjN2I5ZDQ1NGNkNWI3ZDJkNzU1Mzk5YTlmOGNhOWI2NmMyNTJiMGY3ZGEy
10
+ NmVmNmQ3NDVmNWMzMzIyNjhjN2QwZGI2ZjJiN2Y0NDgyMjQxNzQ0MjFmN2Rm
11
+ OWUwMjhhMWEyZmNmMTIzODNkYzdkNDkwYjRkY2M1NjRkNDBkNWI=
12
+ data.tar.gz: !binary |-
13
+ NTE0ODQwZWI0NTgxYjk1MGU5ZGQyMGI3ZWQxOGM2ZGI5OGMxOTUxNjA1ZGM2
14
+ N2U5ZTRiNTQwZmVhM2M0OTg3ZDUwNjI5MGFiNTYwNTlkNmEyNmZmMjQxM2Nk
15
+ YzVjNDA5MjBlYzM3MWQ4ZGIyOGQ0NGY0OTJiNGM5ZWRkOGFjMDg=
data/README.md CHANGED
@@ -33,7 +33,8 @@ Alternatively, Steno can read its configuration from a YAML file in the followin
33
33
  logging:
34
34
  file: /some/path # Optional - path a log file
35
35
  max_retries: 3 # Optional - number of times to retry if a file write fails.
36
- syslog: some_syslog.id # Optional
36
+ syslog: some_syslog.id # Optional - only works on *nix systems
37
+ eventlog: true # Optional - only works on Windows
37
38
  fluentd: # Optional
38
39
  host: fluentd.host
39
40
  port: 9999
@@ -43,13 +43,19 @@ class Steno::Config
43
43
 
44
44
  if hash[:file]
45
45
  max_retries = hash[:max_retries]
46
- opts[:sinks] << Steno::Sink::IO.for_file(hash[:file],
47
- :max_retries => max_retries)
46
+ opts[:sinks] << Steno::Sink::IO.for_file(hash[:file], :max_retries => max_retries)
48
47
  end
49
48
 
50
- if hash[:syslog]
51
- Steno::Sink::Syslog.instance.open(hash[:syslog])
52
- opts[:sinks] << Steno::Sink::Syslog.instance
49
+ if Steno::Sink::WINDOWS
50
+ if hash[:eventlog]
51
+ Steno::Sink::Eventlog.instance.open(hash[:eventlog])
52
+ opts[:sinks] << Steno::Sink::Eventlog.instance
53
+ end
54
+ else
55
+ if hash[:syslog]
56
+ Steno::Sink::Syslog.instance.open(hash[:syslog])
57
+ opts[:sinks] << Steno::Sink::Syslog.instance
58
+ end
53
59
  end
54
60
 
55
61
  if hash[:fluentd]
@@ -64,17 +70,7 @@ class Steno::Config
64
70
  end
65
71
 
66
72
  def symbolize_keys(hash)
67
- hash ||= {}
68
- symbolized = {}
69
- hash.each_key do |key|
70
- if !key.is_a? Symbol
71
- symbolized[key.to_sym] = hash[key]
72
- else
73
- symbolized[key] = hash[key]
74
- end
75
- end
76
-
77
- symbolized
73
+ Hash[hash.each_pair.map { |k, v| [k.to_sym, v] }]
78
74
  end
79
75
  end
80
76
 
@@ -3,3 +3,4 @@ require "steno/sink/io"
3
3
  require "steno/sink/syslog"
4
4
  require "steno/sink/fluentd"
5
5
  require "steno/sink/counter"
6
+ require "steno/sink/eventlog"
@@ -1,7 +1,9 @@
1
+ require "rbconfig"
1
2
  require "thread"
2
3
 
3
4
  module Steno
4
5
  module Sink
6
+ WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
5
7
  end
6
8
  end
7
9
 
@@ -0,0 +1,46 @@
1
+ if Steno::Sink::WINDOWS
2
+ require "steno/sink/base"
3
+
4
+ require "singleton"
5
+ require "thread"
6
+ require 'win32/eventlog'
7
+
8
+ class Steno::Sink::Eventlog < Steno::Sink::Base
9
+ include Singleton
10
+
11
+ LOG_LEVEL_MAP = {
12
+ :fatal => Win32::EventLog::ERROR,
13
+ :error => Win32::EventLog::ERROR,
14
+ :warn => Win32::EventLog::WARN,
15
+ :info => Win32::EventLog::INFO,
16
+ :debug => Win32::EventLog::INFO,
17
+ :debug1 => Win32::EventLog::INFO,
18
+ :debug2 => Win32::EventLog::INFO,
19
+ }
20
+
21
+ def initialize
22
+ super
23
+ @eventlog = nil
24
+ end
25
+
26
+ def open()
27
+ @eventlog = Win32::EventLog::open('Application')
28
+ end
29
+
30
+ def add_record(record)
31
+ msg = @codec.encode_record(record)
32
+ pri = LOG_LEVEL_MAP[record.log_level]
33
+
34
+ @eventlog.report_event(
35
+ :source => 'CloudFoundry',
36
+ :event_type => pri,
37
+ :data => msg
38
+ )
39
+ end
40
+
41
+ def flush
42
+ nil
43
+ end
44
+
45
+ end
46
+ end
@@ -1,56 +1,59 @@
1
- require "steno/sink/base"
2
-
3
- require "singleton"
4
- require "thread"
5
- require "syslog"
6
-
7
- class Steno::Sink::Syslog < Steno::Sink::Base
8
- include Singleton
9
-
10
- MAX_MESSAGE_SIZE = 1024 * 3
11
-
12
- LOG_LEVEL_MAP = {
13
- :fatal => Syslog::LOG_CRIT,
14
- :error => Syslog::LOG_ERR,
15
- :warn => Syslog::LOG_WARNING,
16
- :info => Syslog::LOG_INFO,
17
- :debug => Syslog::LOG_DEBUG,
18
- :debug1 => Syslog::LOG_DEBUG,
19
- :debug2 => Syslog::LOG_DEBUG,
1
+ unless Steno::Sink::WINDOWS
2
+ require "steno/sink/base"
3
+
4
+ require "singleton"
5
+ require "thread"
6
+ require "syslog"
7
+
8
+ class Steno::Sink::Syslog < Steno::Sink::Base
9
+ include Singleton
10
+
11
+ MAX_MESSAGE_SIZE = 1024 * 3
12
+
13
+ LOG_LEVEL_MAP = {
14
+ :fatal => Syslog::LOG_CRIT,
15
+ :error => Syslog::LOG_ERR,
16
+ :warn => Syslog::LOG_WARNING,
17
+ :info => Syslog::LOG_INFO,
18
+ :debug => Syslog::LOG_DEBUG,
19
+ :debug1 => Syslog::LOG_DEBUG,
20
+ :debug2 => Syslog::LOG_DEBUG,
20
21
  }
21
22
 
22
- def initialize
23
- super
24
-
25
- @syslog = nil
26
- @syslog_lock = Mutex.new
27
- end
28
-
29
- def open(identity)
30
- @identity = identity
31
- @syslog = Syslog.open(@identity, Syslog::LOG_PID, Syslog::LOG_USER)
32
- end
33
-
34
- def add_record(record)
35
- record = truncate_record(record)
36
- msg = @codec.encode_record(record)
37
- pri = LOG_LEVEL_MAP[record.log_level]
38
- @syslog_lock.synchronize { @syslog.log(pri, "%s", msg) }
39
- end
40
-
41
- def flush
42
- nil
43
- end
44
- private
45
-
46
- def truncate_record(record)
47
- return record if record.message.size <= MAX_MESSAGE_SIZE
48
-
49
- truncated = record.message.slice(0..(MAX_MESSAGE_SIZE - 1))
50
- truncated << "..."
51
- Steno::Record.new(record.source, record.log_level,
52
- truncated,
53
- [record.file, record.lineno, record.method],
54
- record.data)
23
+ def initialize
24
+ super
25
+
26
+ @syslog = nil
27
+ @syslog_lock = Mutex.new
28
+ end
29
+
30
+ def open(identity)
31
+ @identity = identity
32
+ @syslog = Syslog.open(@identity, Syslog::LOG_PID, Syslog::LOG_USER)
33
+ end
34
+
35
+ def add_record(record)
36
+ record = truncate_record(record)
37
+ msg = @codec.encode_record(record)
38
+ pri = LOG_LEVEL_MAP[record.log_level]
39
+ @syslog_lock.synchronize { @syslog.log(pri, "%s", msg) }
40
+ end
41
+
42
+ def flush
43
+ nil
44
+ end
45
+
46
+ private
47
+
48
+ def truncate_record(record)
49
+ return record if record.message.size <= MAX_MESSAGE_SIZE
50
+
51
+ truncated = record.message.slice(0..(MAX_MESSAGE_SIZE - 1))
52
+ truncated << "..."
53
+ Steno::Record.new(record.source, record.log_level,
54
+ truncated,
55
+ [record.file, record.lineno, record.method],
56
+ record.data)
57
+ end
55
58
  end
56
- end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Steno
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -4,52 +4,106 @@ require "yaml"
4
4
  require "spec_helper"
5
5
 
6
6
  describe Steno::Config do
7
- describe ".from_hash" do
8
- before :each do
9
- @log_path = "some_file"
10
-
11
- @mock_sink_file = mock("sink")
12
- @mock_sink_file.stub(:codec=)
13
- Steno::Sink::IO.should_receive(:for_file).with(@log_path,
14
- :max_retries => 5)
15
- .and_return(@mock_sink_file)
16
7
 
17
- @mock_sink_syslog = mock("sink")
18
- @mock_sink_syslog.stub(:codec=)
19
- @mock_sink_syslog.should_receive(:open).with("test")
20
- Steno::Sink::Syslog.should_receive(:instance).twice()
21
- .and_return(@mock_sink_syslog)
22
- end
8
+ if Steno::Sink::WINDOWS
9
+ describe ".from_hash" do
10
+ before :each do
11
+ @log_path = "some_file"
23
12
 
24
- after :each do
25
- @config = Steno::Config.from_hash(@hash)
13
+ @mock_sink_file = double("sink")
14
+ @mock_sink_file.stub(:codec=)
15
+ Steno::Sink::IO.should_receive(:for_file).with(@log_path,
16
+ :max_retries => 5)
17
+ .and_return(@mock_sink_file)
26
18
 
27
- @config.default_log_level.should == :debug2
28
- @config.context.should.class == Steno::Context::Null
29
- @config.codec.should.class == Steno::Codec::Json
19
+ @mock_sink_eventlog = double("sink")
20
+ @mock_sink_eventlog.stub(:codec=)
21
+ @mock_sink_eventlog.should_receive(:open).with("test")
22
+ Steno::Sink::Eventlog.should_receive(:instance).twice()
23
+ .and_return(@mock_sink_eventlog)
24
+ end
25
+
26
+ after :each do
27
+ @config = Steno::Config.from_hash(@hash)
28
+
29
+ @config.default_log_level.should == :debug2
30
+ @config.context.should.class == Steno::Context::Null
31
+ @config.codec.should.class == Steno::Codec::Json
32
+
33
+ @config.sinks.size.should == 2
34
+ @config.sinks.should =~ [@mock_sink_file, @mock_sink_eventlog]
35
+ end
36
+
37
+ it "should work for symbolized keys" do
38
+ @hash = {
39
+ :file => @log_path,
40
+ :level => "debug2",
41
+ :default_log_level => "warn",
42
+ :eventlog => "test",
43
+ :max_retries => 5,
44
+ }
45
+ end
46
+
47
+ it "should work for non-symbolized keys" do
48
+ @hash = {
49
+ "file" => @log_path,
50
+ "level" => "debug2",
51
+ "default_log_level" => "warn",
52
+ "eventlog" => "test",
53
+ "max_retries" => 5,
54
+ }
55
+ end
30
56
 
31
- @config.sinks.size.should == 2
32
- @config.sinks.should =~ [@mock_sink_file, @mock_sink_syslog]
33
57
  end
58
+ else
59
+ describe ".from_hash" do
60
+ before :each do
61
+ @log_path = "some_file"
62
+
63
+ @mock_sink_file = double("sink")
64
+ @mock_sink_file.stub(:codec=)
65
+ Steno::Sink::IO.should_receive(:for_file).with(@log_path,
66
+ :max_retries => 5)
67
+ .and_return(@mock_sink_file)
34
68
 
35
- it "should work for symbolized keys" do
36
- @hash = {
37
- :file => @log_path,
38
- :level => "debug2",
39
- :default_log_level => "warn",
40
- :syslog => "test",
41
- :max_retries => 5,
42
- }
43
- end
69
+ @mock_sink_syslog = double("sink")
70
+ @mock_sink_syslog.stub(:codec=)
71
+ @mock_sink_syslog.should_receive(:open).with("test")
72
+ Steno::Sink::Syslog.should_receive(:instance).twice()
73
+ .and_return(@mock_sink_syslog)
74
+ end
75
+
76
+ after :each do
77
+ @config = Steno::Config.from_hash(@hash)
78
+
79
+ @config.default_log_level.should == :debug2
80
+ @config.context.should.class == Steno::Context::Null
81
+ @config.codec.should.class == Steno::Codec::Json
82
+
83
+ @config.sinks.size.should == 2
84
+ @config.sinks.should =~ [@mock_sink_file, @mock_sink_syslog]
85
+ end
86
+
87
+ it "should work for symbolized keys" do
88
+ @hash = {
89
+ :file => @log_path,
90
+ :level => "debug2",
91
+ :default_log_level => "warn",
92
+ :syslog => "test",
93
+ :max_retries => 5,
94
+ }
95
+ end
96
+
97
+ it "should work for non-symbolized keys" do
98
+ @hash = {
99
+ "file" => @log_path,
100
+ "level" => "debug2",
101
+ "default_log_level" => "warn",
102
+ "syslog" => "test",
103
+ "max_retries" => 5,
104
+ }
105
+ end
44
106
 
45
- it "should work for non-symbolized keys" do
46
- @hash = {
47
- "file" => @log_path,
48
- "level" => "debug2",
49
- "default_log_level" => "warn",
50
- "syslog" => "test",
51
- "max_retries" => 5,
52
- }
53
107
  end
54
108
  end
55
109
 
@@ -80,47 +134,64 @@ describe Steno::Config do
80
134
  end
81
135
 
82
136
  it "should set the default_log_level if a key with the same name is supplied" do
83
- write_config(@config_path, { "level" => "debug2" })
137
+ write_config(@config_path, {"level" => "debug2"})
84
138
  Steno::Config.from_file(@config_path).default_log_level.should == :debug2
85
139
 
86
- write_config(@config_path, { "default_log_level" => "debug2" })
140
+ write_config(@config_path, {"default_log_level" => "debug2"})
87
141
  Steno::Config.from_file(@config_path).default_log_level.should == :debug2
88
142
  end
89
143
 
90
144
  it "should read the 'level' key if both default_log_level and level are spscified" do
91
- write_config(@config_path, { "level" => "debug2",
92
- "default_log_level" => "warn" })
145
+ write_config(@config_path, {"level" => "debug2",
146
+ "default_log_level" => "warn"})
93
147
  Steno::Config.from_file(@config_path).default_log_level.should == :debug2
94
148
  end
95
149
 
96
150
  it "should add a file sink if the 'file' key is specified" do
97
- write_config(@config_path, { "file" => @log_path, "max_retries" => 2 })
98
- mock_sink = mock("sink")
151
+ write_config(@config_path, {"file" => @log_path, "max_retries" => 2})
152
+ mock_sink = double("sink")
99
153
  mock_sink.stub(:codec=)
100
154
 
101
155
  Steno::Sink::IO.should_receive(:for_file).
102
- with(@log_path, :max_retries => 2).and_return(mock_sink)
156
+ with(@log_path, :max_retries => 2).and_return(mock_sink)
103
157
  config = Steno::Config.from_file(@config_path)
104
158
  config.sinks.size.should == 1
105
159
  config.sinks[0].should == mock_sink
106
160
  end
107
161
 
108
- it "should add a syslog sink if the 'syslog' key is specified" do
109
- write_config(@config_path, { "syslog" => "test" })
110
- mock_sink = mock("sink")
111
- mock_sink.should_receive(:open).with("test")
112
- mock_sink.stub(:codec=)
162
+ if Steno::Sink::WINDOWS
163
+ it "should add a event sink if the 'eventlog' key is specified" do
164
+ write_config(@config_path, {"eventlog" => "test"})
165
+ mock_sink = double("sink")
166
+ mock_sink.should_receive(:open).with("test")
167
+ mock_sink.stub(:codec=)
168
+
169
+ Steno::Sink::Eventlog.should_receive(:instance).twice().and_return(mock_sink)
170
+
171
+ config = Steno::Config.from_file(@config_path)
172
+ config.sinks.size.should == 1
173
+ config.sinks[0].should == mock_sink
174
+ end
175
+ else
176
+ it "should add a syslog sink if the 'syslog' key is specified" do
177
+ write_config(@config_path, {"syslog" => "test"})
178
+ mock_sink = double("sink")
179
+ mock_sink.should_receive(:open).with("test")
180
+ mock_sink.stub(:codec=)
181
+
182
+ Steno::Sink::Syslog.should_receive(:instance).twice().and_return(mock_sink)
183
+
184
+ config = Steno::Config.from_file(@config_path)
185
+ config.sinks.size.should == 1
186
+ config.sinks[0].should == mock_sink
187
+ end
188
+ end
113
189
 
114
- Steno::Sink::Syslog.should_receive(:instance).twice().and_return(mock_sink)
115
190
 
116
- config = Steno::Config.from_file(@config_path)
117
- config.sinks.size.should == 1
118
- config.sinks[0].should == mock_sink
119
- end
120
191
 
121
192
  it "should add an io sink to stdout if no sinks are explicitly specified in the config file" do
122
193
  write_config(@config_path, {})
123
- mock_sink = mock("sink")
194
+ mock_sink = double("sink")
124
195
  mock_sink.stub(:codec=)
125
196
 
126
197
  Steno::Sink::IO.should_receive(:new).with(STDOUT).and_return(mock_sink)
@@ -131,7 +202,7 @@ describe Steno::Config do
131
202
  end
132
203
 
133
204
  it "should merge supplied overrides with the file based config" do
134
- write_config(@config_path, { "default_log_level" => "debug" })
205
+ write_config(@config_path, {"default_log_level" => "debug"})
135
206
 
136
207
  context = Steno::Context::ThreadLocal.new
137
208
  config = Steno::Config.from_file(@config_path,
@@ -144,7 +215,7 @@ describe Steno::Config do
144
215
 
145
216
  def write_config(path, config)
146
217
  File.open(path, "w+") do |f|
147
- f.write(YAML.dump({ "logging" => config }))
218
+ f.write(YAML.dump({"logging" => config}))
148
219
  end
149
220
  end
150
221
  end
@@ -44,7 +44,7 @@ describe Steno::Logger do
44
44
 
45
45
  describe "#log" do
46
46
  it "should not forward any messages for levels that are inactive" do
47
- sink = mock("sink")
47
+ sink = double("sink")
48
48
  sink.should_not_receive(:add_record)
49
49
 
50
50
  my_logger = Steno::Logger.new("test", [sink])
@@ -53,7 +53,7 @@ describe Steno::Logger do
53
53
  end
54
54
 
55
55
  it "should forward messages for levels that are active" do
56
- sink = mock("sink")
56
+ sink = double("sink")
57
57
  sink.should_receive(:add_record).with(any_args())
58
58
 
59
59
  my_logger = Steno::Logger.new("test", [sink])
@@ -74,7 +74,7 @@ describe Steno::Logger do
74
74
  end
75
75
 
76
76
  it "creates a record with the proper level" do
77
- sink = mock("sink")
77
+ sink = double("sink")
78
78
  Steno::Record.should_receive(:new).with("test", :warn, "message", anything, anything).and_call_original
79
79
  sink.stub(:add_record)
80
80
 
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+ if Steno::Sink::WINDOWS
3
+ describe Steno::Sink::Eventlog do
4
+ let(:level) do
5
+ Steno::Logger.lookup_level(:info)
6
+ end
7
+
8
+ let(:record) do
9
+ Steno::Record.new("source", level.name, "message")
10
+ end
11
+
12
+ describe "#add_record" do
13
+
14
+ it "should append an encoded record with the correct priority" do
15
+ eventlog = double("Win32::EventLog")
16
+ Win32::EventLog.should_receive(:open) \
17
+ .with('Application') \
18
+ .and_return(eventlog)
19
+
20
+ sink = Steno::Sink::Eventlog.instance
21
+ sink.open
22
+
23
+ codec = double("codec")
24
+ codec.should_receive(:encode_record).with(record).and_return(record.message)
25
+ sink.codec = codec
26
+
27
+ eventlog.should_receive(:report_event).with(:source => "CloudFoundry",
28
+ :event_type => Win32::EventLog::INFO,
29
+ :data => record.message)
30
+
31
+ sink.add_record(record)
32
+ end
33
+ end
34
+
35
+ describe "#flush" do
36
+ it "should do nothing" do
37
+ Steno::Sink::Eventlog.instance.flush
38
+ end
39
+ end
40
+ end
41
+ end
@@ -36,7 +36,7 @@ describe Steno::Sink::IO do
36
36
 
37
37
  describe "#add_record" do
38
38
  it "should post an record with the correct tag" do
39
- fluentd = mock("fluentd")
39
+ fluentd = double("fluentd")
40
40
  Fluent::Logger::FluentLogger.should_receive(:new).and_return(fluentd)
41
41
  fluentd.should_receive(:post).with("source", record)
42
42
  sink = Steno::Sink::Fluentd.new()
@@ -11,12 +11,12 @@ describe Steno::Sink::IO do
11
11
 
12
12
  describe ".for_file" do
13
13
  it "should return a new sink configured to append to the file at path with autosync set to true by default" do
14
- mock_handle = mock("file handle")
14
+ mock_handle = double("file handle")
15
15
 
16
16
  File.should_receive(:open).with("path", "a+").and_return(mock_handle)
17
17
  mock_handle.should_receive(:sync=).with(true)
18
18
 
19
- mock_sink = mock("sink")
19
+ mock_sink = double("sink")
20
20
  Steno::Sink::IO.should_receive(:new).with(mock_handle,
21
21
  :max_retries => 10).
22
22
  and_return(mock_sink)
@@ -27,12 +27,12 @@ describe Steno::Sink::IO do
27
27
  end
28
28
 
29
29
  it "should return a new sink configured to append to the file at path with specified options" do
30
- mock_handle = mock("file handle")
30
+ mock_handle = double("file handle")
31
31
 
32
32
  File.should_receive(:open).with("path", "a+").and_return(mock_handle)
33
33
  mock_handle.should_receive(:sync=).with(false)
34
34
 
35
- mock_sink = mock("sink")
35
+ mock_sink = double("sink")
36
36
  Steno::Sink::IO.should_receive(:new).with(mock_handle,
37
37
  :max_retries => 10).
38
38
  and_return(mock_sink)
@@ -46,20 +46,20 @@ describe Steno::Sink::IO do
46
46
 
47
47
  describe "#add_record" do
48
48
  it "should encode the record and write it to the underlying io object" do
49
- codec = mock("codec")
49
+ codec = double("codec")
50
50
  codec.should_receive(:encode_record).with(record).and_return(record.message)
51
51
 
52
- io = mock("io")
52
+ io = double("io")
53
53
  io.should_receive(:write).with(record.message)
54
54
 
55
55
  Steno::Sink::IO.new(io, :codec => codec).add_record(record)
56
56
  end
57
57
 
58
58
  it "should by default not retry on IOError" do
59
- codec = mock("codec")
59
+ codec = double("codec")
60
60
  codec.should_receive(:encode_record).with(record).and_return(record.message)
61
61
 
62
- io = mock("io")
62
+ io = double("io")
63
63
 
64
64
  io.should_receive(:write).with(record.message).ordered.and_raise(IOError)
65
65
 
@@ -69,10 +69,10 @@ describe Steno::Sink::IO do
69
69
  end
70
70
 
71
71
  it "should retry not more than specified number of times on IOError" do
72
- codec = mock("codec")
72
+ codec = double("codec")
73
73
  codec.should_receive(:encode_record).with(record).and_return(record.message)
74
74
 
75
- io = mock("io")
75
+ io = double("io")
76
76
 
77
77
  io.should_receive(:write).exactly(3).times.with(record.message).
78
78
  and_raise(IOError)
@@ -84,10 +84,10 @@ describe Steno::Sink::IO do
84
84
  end
85
85
 
86
86
  it "should retry on IOError and succeed" do
87
- codec = mock("codec")
87
+ codec = double("codec")
88
88
  codec.should_receive(:encode_record).with(record).and_return(record.message)
89
89
 
90
- io = mock("io")
90
+ io = double("io")
91
91
  io.should_receive(:write).with(record.message).once.
92
92
  and_raise(IOError)
93
93
  io.should_receive(:write).with(record.message).once.ordered.
@@ -102,7 +102,7 @@ describe Steno::Sink::IO do
102
102
 
103
103
  describe "#flush" do
104
104
  it "should call flush on the underlying io object" do
105
- io = mock("io")
105
+ io = double("io")
106
106
  io.should_receive(:flush)
107
107
 
108
108
  Steno::Sink::IO.new(io).flush
@@ -1,73 +1,74 @@
1
1
  require "spec_helper"
2
+ unless Steno::Sink::WINDOWS
3
+ describe Steno::Sink::Syslog do
4
+ let(:level) do
5
+ Steno::Logger.lookup_level(:info)
6
+ end
2
7
 
3
- describe Steno::Sink::Syslog do
4
- let(:level) do
5
- Steno::Logger.lookup_level(:info)
6
- end
7
-
8
- let(:record) do
9
- Steno::Record.new("source", level.name, "message")
10
- end
8
+ let(:record) do
9
+ Steno::Record.new("source", level.name, "message")
10
+ end
11
11
 
12
- let(:record_with_big_message) do
13
- Steno::Record.new("source", level.name,
14
- "a" * (Steno::Sink::Syslog::MAX_MESSAGE_SIZE + 1))
15
- end
12
+ let(:record_with_big_message) do
13
+ Steno::Record.new("source", level.name,
14
+ "a" * (Steno::Sink::Syslog::MAX_MESSAGE_SIZE + 1))
15
+ end
16
16
 
17
- describe "#add_record" do
18
- it "should append an encoded record with the correct priority" do
19
- identity = "test"
17
+ describe "#add_record" do
18
+ it "should append an encoded record with the correct priority" do
19
+ identity = "test"
20
20
 
21
- syslog = mock("syslog")
22
- Syslog.should_receive(:open) \
21
+ syslog = double("syslog")
22
+ Syslog.should_receive(:open) \
23
23
  .with(identity, Syslog::LOG_PID, Syslog::LOG_USER) \
24
24
  .and_return(syslog)
25
25
 
26
- sink = Steno::Sink::Syslog.instance
27
- sink.open(identity)
26
+ sink = Steno::Sink::Syslog.instance
27
+ sink.open(identity)
28
28
 
29
- codec = mock("codec")
30
- codec.should_receive(:encode_record).with(record).and_return(record.message)
31
- sink.codec = codec
29
+ codec = double("codec")
30
+ codec.should_receive(:encode_record).with(record).and_return(record.message)
31
+ sink.codec = codec
32
32
 
33
- syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", record.message)
33
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", record.message)
34
34
 
35
- sink.add_record(record)
36
- end
35
+ sink.add_record(record)
36
+ end
37
37
 
38
- it "should truncate the record message if its greater than than allowed size" do
39
- identity = "test"
38
+ it "should truncate the record message if its greater than than allowed size" do
39
+ identity = "test"
40
40
 
41
- syslog = mock("syslog")
42
- Syslog.should_receive(:open) \
41
+ syslog = double("syslog")
42
+ Syslog.should_receive(:open) \
43
43
  .with(identity, Syslog::LOG_PID, Syslog::LOG_USER) \
44
44
  .and_return(syslog)
45
45
 
46
- sink = Steno::Sink::Syslog.instance
47
- sink.open(identity)
46
+ sink = Steno::Sink::Syslog.instance
47
+ sink.open(identity)
48
48
 
49
- truncated = record_with_big_message.message.
50
- slice(0..(Steno::Sink::Syslog::MAX_MESSAGE_SIZE) - 1)
51
- truncated << "..."
52
- codec = mock("codec")
53
- codec.should_receive(:encode_record) do |*args|
54
- args.size.should == 1
55
- args[0].message.should == truncated
49
+ truncated = record_with_big_message.message.
50
+ slice(0..(Steno::Sink::Syslog::MAX_MESSAGE_SIZE) - 1)
51
+ truncated << "..."
52
+ codec = double("codec")
53
+ codec.should_receive(:encode_record) do |*args|
54
+ args.size.should == 1
55
+ args[0].message.should == truncated
56
56
 
57
- next args[0].message
58
- end
57
+ next args[0].message
58
+ end
59
59
 
60
- sink.codec = codec
60
+ sink.codec = codec
61
61
 
62
- syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", truncated)
62
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", truncated)
63
63
 
64
- sink.add_record(record_with_big_message)
64
+ sink.add_record(record_with_big_message)
65
+ end
65
66
  end
66
- end
67
67
 
68
- describe "#flush" do
69
- it "should do nothing" do
70
- Steno::Sink::Syslog.instance.flush
68
+ describe "#flush" do
69
+ it "should do nothing" do
70
+ Steno::Sink::Syslog.instance.flush
71
+ end
71
72
  end
72
73
  end
73
74
  end
@@ -28,9 +28,14 @@ Gem::Specification.new do |gem|
28
28
  gem.add_dependency("grape")
29
29
  gem.add_dependency("yajl-ruby", "~> 1.0")
30
30
  gem.add_dependency("fluent-logger")
31
-
31
+
32
32
  gem.add_development_dependency("ci_reporter")
33
33
  gem.add_development_dependency("rack-test")
34
34
  gem.add_development_dependency("rake")
35
35
  gem.add_development_dependency("rspec")
36
+
37
+ if RUBY_PLATFORM=~ /mswin|mingw|cygwin/
38
+ gem.platform = Gem::Platform::CURRENT
39
+ gem.add_dependency("win32-eventlog")
40
+ end
36
41
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steno
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - mpage
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: grape
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: yajl-ruby
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fluent-logger
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: ci_reporter
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rack-test
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -146,6 +131,7 @@ files:
146
131
  - lib/steno/record.rb
147
132
  - lib/steno/sink/base.rb
148
133
  - lib/steno/sink/counter.rb
134
+ - lib/steno/sink/eventlog.rb
149
135
  - lib/steno/sink/fluentd.rb
150
136
  - lib/steno/sink/io.rb
151
137
  - lib/steno/sink/syslog.rb
@@ -170,6 +156,7 @@ files:
170
156
  - spec/unit/logger_spec.rb
171
157
  - spec/unit/record_spec.rb
172
158
  - spec/unit/sink/counter_spec.rb
159
+ - spec/unit/sink/eventlog_spec.rb
173
160
  - spec/unit/sink/fluentd_spec.rb
174
161
  - spec/unit/sink/io_spec.rb
175
162
  - spec/unit/sink/syslog_spec.rb
@@ -178,27 +165,26 @@ files:
178
165
  - steno.gemspec
179
166
  homepage: http://www.cloudfoundry.org
180
167
  licenses: []
168
+ metadata: {}
181
169
  post_install_message:
182
170
  rdoc_options: []
183
171
  require_paths:
184
172
  - lib
185
173
  required_ruby_version: !ruby/object:Gem::Requirement
186
- none: false
187
174
  requirements:
188
175
  - - ! '>='
189
176
  - !ruby/object:Gem::Version
190
177
  version: '0'
191
178
  required_rubygems_version: !ruby/object:Gem::Requirement
192
- none: false
193
179
  requirements:
194
180
  - - ! '>='
195
181
  - !ruby/object:Gem::Version
196
182
  version: '0'
197
183
  requirements: []
198
184
  rubyforge_project:
199
- rubygems_version: 1.8.23
185
+ rubygems_version: 2.0.7
200
186
  signing_key:
201
- specification_version: 3
187
+ specification_version: 4
202
188
  summary: A logging library.
203
189
  test_files:
204
190
  - spec/spec_helper.rb
@@ -215,6 +201,7 @@ test_files:
215
201
  - spec/unit/logger_spec.rb
216
202
  - spec/unit/record_spec.rb
217
203
  - spec/unit/sink/counter_spec.rb
204
+ - spec/unit/sink/eventlog_spec.rb
218
205
  - spec/unit/sink/fluentd_spec.rb
219
206
  - spec/unit/sink/io_spec.rb
220
207
  - spec/unit/sink/syslog_spec.rb