dohlog 0.1.11 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'doh/log/severity'
1
+ require 'dohlog/severity'
2
2
 
3
3
  module DohLog
4
4
 
@@ -1,12 +1,10 @@
1
1
  class Module
2
- undef dohlog
3
2
  def dohlog
4
3
  @dohlog ||= DohLog::Interface.new(self.to_s)
5
4
  end
6
5
  end
7
6
 
8
7
  class Object
9
- undef dohlog
10
8
  def dohlog
11
9
  self.class.dohlog
12
10
  end
@@ -0,0 +1,55 @@
1
+ require 'dohlog/event'
2
+
3
+ module DohLog
4
+
5
+ class Interface
6
+ @@acceptor = nil
7
+ @@enabled = false
8
+
9
+ def self.setup(acceptor)
10
+ @@acceptor = acceptor
11
+ @@enabled = true
12
+ end
13
+
14
+ def self.shutdown
15
+ @@acceptor.shutdown
16
+ end
17
+
18
+ def self.enable
19
+ @@enabled = true
20
+ end
21
+
22
+ def self.disable
23
+ @@enabled = false
24
+ end
25
+
26
+ def initialize(location)
27
+ @location = location
28
+ end
29
+
30
+ def debug(msg, exception = nil)
31
+ if @@enabled
32
+ @@acceptor.add(Event.new(DohLog::DEBUG, msg, @location, exception))
33
+ end
34
+ end
35
+
36
+ def info(msg, exception = nil)
37
+ if @@enabled
38
+ @@acceptor.add(Event.new(DohLog::INFO, msg, @location, exception))
39
+ end
40
+ end
41
+
42
+ def warn(msg, exception = nil)
43
+ if @@enabled
44
+ @@acceptor.add(Event.new(DohLog::WARN, msg, @location, exception))
45
+ end
46
+ end
47
+
48
+ def error(msg, exception = nil)
49
+ if @@enabled
50
+ @@acceptor.add(Event.new(DohLog::ERROR, msg, @location, exception))
51
+ end
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,13 @@
1
+ module DohLog
2
+
3
+ DEBUG = 0
4
+ INFO = 1
5
+ WARN = 2
6
+ ERROR = 3
7
+ SEVERITY_LEVELS = %w(debug info WARNING ERROR)
8
+
9
+ def self.severity_text(level)
10
+ SEVERITY_LEVELS[level]
11
+ end
12
+
13
+ end
data/lib/dohlog.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'dohlog/interface'
2
+ require 'dohlog/integrate'
3
+ require 'dohlog/stream_acceptor'
4
+
5
+ module DohLog
6
+ extend self
7
+
8
+ def setup(acceptor)
9
+ DohLog::Interface.setup(acceptor)
10
+ end
11
+
12
+ def shutdown
13
+ DohLog::Interface.shutdown
14
+ end
15
+
16
+ def enable
17
+ DohLog::Interface.enable
18
+ end
19
+
20
+ def disable
21
+ DohLog::Interface.disable
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-20 00:00:00.000000000 Z
13
+ date: 2013-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: dohutil
@@ -36,18 +36,16 @@ extensions: []
36
36
  extra_rdoc_files:
37
37
  - MIT-LICENSE
38
38
  files:
39
- - lib/doh/log/append_acceptor.rb
40
- - lib/doh/log/email_acceptor.rb
41
- - lib/doh/log/event.rb
42
- - lib/doh/log/filter_acceptor.rb
43
- - lib/doh/log/integrate.rb
44
- - lib/doh/log/interface.rb
45
- - lib/doh/log/memory_acceptor.rb
46
- - lib/doh/log/multi_acceptor.rb
47
- - lib/doh/log/severity.rb
48
- - lib/doh/log/stream_acceptor.rb
49
- - lib/doh/log/unintegrate.rb
50
- - lib/doh/log.rb
39
+ - lib/dohlog/append_acceptor.rb
40
+ - lib/dohlog/event.rb
41
+ - lib/dohlog/filter_acceptor.rb
42
+ - lib/dohlog/integrate.rb
43
+ - lib/dohlog/interface.rb
44
+ - lib/dohlog/memory_acceptor.rb
45
+ - lib/dohlog/multi_acceptor.rb
46
+ - lib/dohlog/severity.rb
47
+ - lib/dohlog/stream_acceptor.rb
48
+ - lib/dohlog.rb
51
49
  - MIT-LICENSE
52
50
  homepage: https://github.com/atpsoft/dohlog
53
51
  licenses:
@@ -1,27 +0,0 @@
1
- require 'net/smtp'
2
-
3
- module DohLog
4
-
5
- class EmailAcceptor
6
- # required config fields are :from, :to, :server
7
- def initialize(config)
8
- @config = config
9
- @msg_start = "From:#{config[:from]}\nTo:#{config[:to].join(', ')}\nContent-Type: text/plain\nSubject:"
10
- end
11
-
12
- def add(event)
13
- msg = "#{@msg_start}#{event.severity_text}: #{event.msg}\n\n#{event.summary}\n#{event.exception_text}"
14
- Net::SMTP.start(@config[:server]) do |smtp|
15
- begin
16
- smtp.send_message(msg, @config[:from], @config[:to])
17
- rescue => excpt
18
- $stderr.puts "DohLog EmailAcceptor send failed: #{excpt}"
19
- end
20
- end
21
- end
22
-
23
- def shutdown
24
- end
25
- end
26
-
27
- end
@@ -1,45 +0,0 @@
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, exception = nil)
21
- @@acceptor.add(Event.new(DohLog::DEBUG, msg, @location, exception))
22
- end
23
-
24
- def info(msg, exception = nil)
25
- @@acceptor.add(Event.new(DohLog::INFO, msg, @location, exception))
26
- end
27
-
28
- def notify(msg, exception = nil)
29
- @@acceptor.add(Event.new(DohLog::NOTIFY, msg, @location, exception))
30
- end
31
-
32
- def warn(msg, exception = nil)
33
- @@acceptor.add(Event.new(DohLog::WARN, msg, @location, exception))
34
- end
35
-
36
- def error(msg, exception = nil)
37
- @@acceptor.add(Event.new(DohLog::ERROR, msg, @location, exception))
38
- end
39
-
40
- def fatal(msg, exception = nil)
41
- @@acceptor.add(Event.new(DohLog::FATAL, msg, @location, exception))
42
- end
43
- end
44
-
45
- end
@@ -1,15 +0,0 @@
1
- module DohLog
2
-
3
- DEBUG = 0
4
- INFO = 1
5
- NOTIFY = 2
6
- WARN = 3
7
- ERROR = 4
8
- FATAL = 5
9
- SEVERITY_LEVELS = %w(debug info NOTIFY WARNING ERROR ***FATAL***)
10
-
11
- def self.severity_text(level)
12
- SEVERITY_LEVELS[level]
13
- end
14
-
15
- end
@@ -1,7 +0,0 @@
1
- class Module
2
- undef dohlog
3
- end
4
-
5
- class Object
6
- undef dohlog
7
- end
data/lib/doh/log.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'doh/log/stub'
2
- require 'doh/log/interface'
3
-
4
- module DohLog
5
-
6
- def self.setup(acceptor)
7
- require 'doh/log/integrate'
8
- DohLog::Interface.setup(acceptor)
9
- end
10
-
11
- def self.shutdown
12
- DohLog::Interface.shutdown
13
- end
14
-
15
- def self.disable
16
- return if dohlog == StubInterface
17
- load 'doh/log/unintegrate.rb'
18
- load 'doh/log/stub.rb'
19
- end
20
-
21
- def self.enable
22
- return unless dohlog == StubInterface
23
- load 'doh/log/integrate.rb'
24
- end
25
-
26
- end
File without changes
File without changes
File without changes
File without changes
File without changes