transaction_logger 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 544d8e3034117695aa67e4d1fa207bb87e060dcf
4
- data.tar.gz: bb1e5adbb2abfa94408b9c91fe5e401ec742affb
3
+ metadata.gz: 9dcfe3a7f8cbdde324e95e0a246a411907faf9f5
4
+ data.tar.gz: c7747c2a99b7705e3689b317276969e41e902b3f
5
5
  SHA512:
6
- metadata.gz: 18e1641a904647a7385544cf2077d38e547d876b5a517a858f685d711e43bcf6b76db33aabb41089bec3c27f0a7c29b89193c061914cf3c05da85bb35877d98d
7
- data.tar.gz: d58c1a65794727de53cf7e03fd94acfc3a75c9f2f38f047e0fd9a3cff3bcc45ab5229923efdf1d3f4b2a04988c5ccd7415e83dbf573a9c164f5f208732c1e18e
6
+ metadata.gz: 81fb304e54412d6ed784684b14b64145ee3796b0fe841fb4b41485cd8790068c9b703cc07fe89da23b629f935f3b6cf1d75797544b3bd81a73f9cef49c79f64f
7
+ data.tar.gz: 47e00a81952e0633aa9974bea50b7cf9c79f6c72d8899baa315be4330615a43c9d9210409ebedf31d7d89838b46bdb1ff058cc73d8387b0415d0c5935c068ca1
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.gem
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Blinkist TransactionLogger
2
- [ ![Codeship Status for blinkist/transaction_logger](https://codeship.com/projects/fb9745c0-edc7-0132-b6b1-1efd3f886df2/status?branch=master)](https://codeship.com/projects/84119) [![Code Climate](https://codeclimate.com/github/blinkist/transaction_logger/badges/gpa.svg)](https://codeclimate.com/github/blinkist/transaction_logger)
2
+ [ ![Codeship Status for blinkist/transaction_logger](https://codeship.com/projects/fb9745c0-edc7-0132-b6b1-1efd3f886df2/status?branch=master)](https://codeship.com/projects/84119) [![Code Climate](https://codeclimate.com/github/blinkist/transaction_logger/badges/gpa.svg)](https://codeclimate.com/github/blinkist/transaction_logger) [![Dependency Status](https://www.versioneye.com/ruby/transaction_logger/badge.svg)](https://www.versioneye.com/ruby/transaction_logger/)
3
3
 
4
4
  Business Transactions Logger for Ruby that compiles contextual logging information and can send it to a configured logging service such as Logger or Loggly in a nested hash.
5
5
 
@@ -34,6 +34,19 @@ logger = Logger.new STDOUT # Ruby default logger setup
34
34
  TransactionLogger.logger = logger
35
35
  ```
36
36
 
37
+ Calling Transaction_Logger.logger with no parameter sets the logger to a new instance of Logger as shown above.
38
+
39
+ You can add a prefix to every hash key in the log by using the class method log_prefix:
40
+
41
+ ```ruby
42
+ TransactionLogger.log_prefix = "transaction_logger_"
43
+ # {
44
+ # "transaction_logger_name" => "some name"
45
+ # "transaction_logger_context" => { "user_id" => 1 }
46
+ # ...
47
+ # }
48
+ ```
49
+
37
50
  Wrap a business transaction method with a TransactionLogger lambda:
38
51
 
39
52
  ```ruby
@@ -54,6 +67,17 @@ t.log "A message you want logged"
54
67
 
55
68
  ### Example
56
69
 
70
+ Initial setup, in a config file:
71
+
72
+ ```ruby
73
+ # Sets output to new instance of Logger
74
+ TransactionLogger.logger
75
+
76
+ # Sets the prefix of each hash key in the log to "transaction_"
77
+ # eg. An error message has key: "transaction_error_message"
78
+ TransactionLogger.log_prefix = "transaction_"
79
+ ```
80
+
57
81
  Here is a transaction that raises an error:
58
82
 
59
83
  ```ruby
@@ -77,17 +101,17 @@ The expected output is:
77
101
 
78
102
  ```json
79
103
  {
80
- "transaction_name": "ExampleClass.some_method",
81
- "transaction_context": {
104
+ "name": "ExampleClass.some_method",
105
+ "context": {
82
106
  "some_id": 12
83
107
  },
84
- "transaction_duration": 0.112,
85
- "transaction_history": [{
86
- "transaction_info": "Trying something complex"
108
+ "duration": 0.112,
109
+ "history": [{
110
+ "info": "Trying something complex"
87
111
  }, {
88
- "transaction_error_message": "Error",
89
- "transaction_error_class": "RuntimeError",
90
- "transaction_error_backtrace": [
112
+ "error_message": "Error",
113
+ "error_class": "RuntimeError",
114
+ "error_backtrace": [
91
115
  "example.rb:84:in `block in nested_method'",
92
116
  ".../TransactionLogger_Example/transaction_logger.rb:26:in `call'",
93
117
  ".../TransactionLogger_Example/transaction_logger.rb:26:in `run'",
@@ -1,3 +1,3 @@
1
1
  class TransactionLogger
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -54,12 +54,22 @@ class TransactionLogger
54
54
  @@logger ||= Logger.new(STDOUT)
55
55
  end
56
56
 
57
+ # Sets the hash keys on the TransactionLogger's log to have a prefix.
57
58
  #
59
+ # Using .log_prefix "str_", the output of the log hash will contain keys prefixed
60
+ # with "str_", such as { "str_name" => "Class.method" }.
61
+ #
62
+ # @param prefix [#to_s] Any String or Object that responds to to_s
58
63
  #
59
64
  def self.log_prefix=(prefix)
60
65
  @@prefix = "#{prefix}"
61
66
  end
62
67
 
68
+ # @private
69
+ # Returns the log_prefix
70
+ #
71
+ # @return [String] The currently stored prefix.
72
+ #
63
73
  def self.log_prefix
64
74
  @@prefix
65
75
  end
@@ -9,11 +9,11 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["John Donner", "Sebastian Schleicher"]
10
10
  spec.email = ["johnbdonner@gmail.com", "sebastian.julius@gmail.com"]
11
11
  spec.summary = %q{Contextual Business Transaction Logger for Ruby}
12
- spec.description = %q{A logger that silently collects information in the \
13
- background and when an error is raised, logs a hash either \
14
- out to the System or pushes the log to a service such as \
15
- Loggly. The log hash contains information such as the \
16
- backtrace, any logs from calling classes and methods, \
12
+ spec.description = %q{A logger that silently collects information in the
13
+ background and when an error is raised, logs a hash either
14
+ out to the System or pushes the log to a service such as
15
+ Loggly. The log hash contains information such as the
16
+ backtrace, any logs from calling classes and methods,
17
17
  and configurable contextual information.}
18
18
  spec.homepage = "https://github.com/blinkist/transaction_logger"
19
19
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transaction_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Donner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-03 00:00:00.000000000 Z
12
+ date: 2015-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -109,13 +109,12 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- description: |-
113
- A logger that silently collects information in the \
114
- background and when an error is raised, logs a hash either \
115
- out to the System or pushes the log to a service such as \
116
- Loggly. The log hash contains information such as the \
117
- backtrace, any logs from calling classes and methods, \
118
- and configurable contextual information.
112
+ description: "A logger that silently collects information in the\n background
113
+ and when an error is raised, logs a hash either\n out to
114
+ the System or pushes the log to a service such as\n Loggly.
115
+ The log hash contains information such as the\n backtrace,
116
+ any logs from calling classes and methods, \n and configurable
117
+ contextual information."
119
118
  email:
120
119
  - johnbdonner@gmail.com
121
120
  - sebastian.julius@gmail.com