datalogger 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -1,7 +1,10 @@
1
- # DataLogger (alpha)
2
- A simple structured data logger. Pass it a hash, and it takes care of storing it to the data sink of your choice (currently stdout, though plugins are on the way).
1
+ # DataLogger (alpha - API should be considered unstable)
2
+ A simple structured data logger. Pass it a hash, and it takes care of emitting to stdout.
3
+
4
+ Inspiration largely comes from ["The Twelve-Factor App"](http://www.12factor.net/logs) by Adam Wiggins, Mark McGranaghan's ["Logs as Data"](https://github.com/relevance/clojure-conj/blob/master/2011-slides/mark-mcgranaghan-logs-as-data.pdf) talk, and various experiments at [Heroku](http://heroku.com).
3
5
 
4
6
  ## Usage
7
+ ### The most obvious way:
5
8
  ```ruby
6
9
  require 'datalogger'
7
10
 
@@ -32,3 +35,48 @@ This will generate a message that looks something like so:
32
35
  myapp action=create_user at=start
33
36
  myapp action=create_user at=finish elapsed=0.003116
34
37
  ```
38
+
39
+ ###As a singleton:
40
+
41
+ ```ruby
42
+ require 'datalogger'
43
+
44
+ DataLogger::Logger.component = 'myapp'
45
+ DataLogger::Logger.log a: 1, b: 2, c: 3
46
+ ```
47
+
48
+ ### Mixing in instance methods
49
+
50
+ ```ruby
51
+ require 'datalogger'
52
+
53
+ DataLogger::Logger.component = 'myapp'
54
+
55
+ class MyThing
56
+ include DataLogger
57
+
58
+ def do_something
59
+ log(action: 'do_something') do
60
+ # code goes here
61
+ end
62
+ end
63
+ end
64
+ ```
65
+
66
+ ### Mixing in class methods
67
+ ```ruby
68
+ require 'datalogger'
69
+
70
+ DataLogger::Logger.component = 'myapp'
71
+
72
+ class MyThing
73
+ extend DataLogger
74
+
75
+ def self.do_something
76
+ log(action: 'do_something') do
77
+ # code goes here
78
+ end
79
+ end
80
+ end
81
+ ```
82
+
@@ -3,11 +3,7 @@ require "datalogger/logger"
3
3
  require "datalogger/sinks/stdout"
4
4
 
5
5
  module DataLogger
6
- def datalogger
7
- Logger.global_logger
8
- end
9
-
10
6
  def log(data, &blk)
11
- datalogger.log(data, &blk)
7
+ Logger.global_logger.log(data, &blk)
12
8
  end
13
- end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module DataLogger
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  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.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: