dohlog 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/lib/doh/log.rb +2 -0
- data/lib/doh/log/event.rb +38 -0
- data/lib/doh/log/integrate.rb +13 -0
- data/lib/doh/log/interface.rb +49 -0
- data/lib/doh/log/severity.rb +14 -0
- data/lib/doh/log/stream_acceptor.rb +26 -0
- metadata +67 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Makani Mason, Kem Mason
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/doh/log.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'doh/log/severity'
|
2
|
+
|
3
|
+
module DohLog
|
4
|
+
|
5
|
+
class Event
|
6
|
+
attr_accessor :severity, :msg, :location, :exception, :time
|
7
|
+
|
8
|
+
def initialize(severity, msg, location = '', exception = nil)
|
9
|
+
@severity, @msg, @location, @exception = severity, msg, location, exception
|
10
|
+
@time = Time.now
|
11
|
+
end
|
12
|
+
|
13
|
+
def severity_text
|
14
|
+
DohLog::severity_text(@severity)
|
15
|
+
end
|
16
|
+
|
17
|
+
def time_text
|
18
|
+
@time.strftime("%H:%M:%S.") << "%03d" % (@time.usec / 1000)
|
19
|
+
end
|
20
|
+
|
21
|
+
def datetime_text
|
22
|
+
@time.strftime("%Y-%m-%d %H:%M:%S.") << "%03d" % (@time.usec / 1000)
|
23
|
+
end
|
24
|
+
|
25
|
+
def exception_name
|
26
|
+
if @exception then @exception.class.to_s else '' end
|
27
|
+
end
|
28
|
+
|
29
|
+
def call_stack
|
30
|
+
if @exception then @exception.backtrace else caller end
|
31
|
+
end
|
32
|
+
|
33
|
+
def summary
|
34
|
+
"#{datetime_text} [#{severity_text}] (#{location}) : #{msg}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'doh/log/event'
|
2
|
+
|
3
|
+
module DohLog
|
4
|
+
|
5
|
+
class Interface
|
6
|
+
@@acceptor = nil
|
7
|
+
|
8
|
+
def self.setup(acceptor)
|
9
|
+
@@acceptor = acceptor
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.shutdown
|
13
|
+
@@acceptor.shutdown
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(location)
|
17
|
+
@location = location
|
18
|
+
end
|
19
|
+
|
20
|
+
def debug(msg)
|
21
|
+
@@acceptor.add(Event.new(DohLog::DEBUG, msg, @location))
|
22
|
+
end
|
23
|
+
|
24
|
+
def info(msg)
|
25
|
+
@@acceptor.add(Event.new(DohLog::INFO, msg, @location))
|
26
|
+
end
|
27
|
+
|
28
|
+
def warn(msg)
|
29
|
+
@@acceptor.add(Event.new(DohLog::WARN, msg, @location))
|
30
|
+
end
|
31
|
+
|
32
|
+
def error(msg, exception = nil)
|
33
|
+
@@acceptor.add(Event.new(DohLog::ERROR, msg, @location, exception))
|
34
|
+
end
|
35
|
+
|
36
|
+
def fatal(msg, exception = nil)
|
37
|
+
@@acceptor.add(Event.new(DohLog::FATAL, msg, @location, exception))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.setup(acceptor)
|
42
|
+
DohLog::Interface.setup(acceptor)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.shutdown
|
46
|
+
DohLog::Interface.shutdown
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DohLog
|
2
|
+
|
3
|
+
class StreamAcceptor
|
4
|
+
attr_reader :ios
|
5
|
+
|
6
|
+
def initialize(flush, ios = nil)
|
7
|
+
@flush = flush
|
8
|
+
@ios = ios || STDOUT
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(event)
|
12
|
+
@ios.puts(event.summary)
|
13
|
+
if event.severity >= DohLog::ERROR
|
14
|
+
@ios.puts("=> exception: #{event.exception_name}")
|
15
|
+
@ios.puts("=> stack: #{event.call_stack}")
|
16
|
+
end
|
17
|
+
@ios.fsync if @flush
|
18
|
+
end
|
19
|
+
|
20
|
+
def shutdown
|
21
|
+
@ios.fsync
|
22
|
+
@ios = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dohlog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Makani Mason
|
9
|
+
- Kem Mason
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-02-07 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: dohutil
|
17
|
+
requirement: &70197583966520 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70197583966520
|
26
|
+
description: Logging framework built to be fast and flexible by leveraging the power
|
27
|
+
of zeromq.
|
28
|
+
email:
|
29
|
+
- devinfo@atpsoft.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- MIT-LICENSE
|
34
|
+
files:
|
35
|
+
- lib/doh/log/event.rb
|
36
|
+
- lib/doh/log/integrate.rb
|
37
|
+
- lib/doh/log/interface.rb
|
38
|
+
- lib/doh/log/severity.rb
|
39
|
+
- lib/doh/log/stream_acceptor.rb
|
40
|
+
- lib/doh/log.rb
|
41
|
+
- MIT-LICENSE
|
42
|
+
homepage: https://github.com/atpsoft/dohlog
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.2
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.10
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: zeromq powered logging framework
|
67
|
+
test_files: []
|