datalogger 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,25 @@
1
1
  module DataLogger
2
2
  class Logger
3
3
  attr_accessor :component, :sinks
4
-
4
+
5
+ def self.global_logger
6
+ @global_logger ||= new
7
+ end
8
+
9
+ def self.component=(component)
10
+ global_logger.component = component
11
+ end
12
+
13
+ def self.log(data, &blk)
14
+ global_logger.log(data, &blk)
15
+ end
16
+
5
17
  def initialize(component='app')
6
18
  self.component = component
7
19
  self.sinks = []
8
20
  self.sinks << Sinks::STDOUT.new
9
21
  end
10
22
 
11
- def log_to_sinks(data)
12
- self.sinks.each do |sink|
13
- sink.log(self.component, data)
14
- end
15
- end
16
-
17
23
  def log(data, &blk)
18
24
  if data.kind_of?(String)
19
25
  data = { message: data }
@@ -31,5 +37,11 @@ module DataLogger
31
37
  nil
32
38
  end
33
39
  end
40
+
41
+ def log_to_sinks(data)
42
+ self.sinks.each do |sink|
43
+ sink.log(self.component, data)
44
+ end
45
+ end
34
46
  end
35
47
  end
@@ -1,3 +1,3 @@
1
1
  module DataLogger
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/datalogger.rb CHANGED
@@ -1,3 +1,13 @@
1
1
  require "datalogger/version"
2
2
  require "datalogger/logger"
3
- require "datalogger/sinks/stdout"
3
+ require "datalogger/sinks/stdout"
4
+
5
+ module DataLogger
6
+ def datalogger
7
+ Logger.global_logger
8
+ end
9
+
10
+ def log(data, &blk)
11
+ datalogger.log(data, &blk)
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datalogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-25 00:00:00.000000000Z
12
+ date: 2012-01-26 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Easy to use structured data logger
15
15
  email: