lorekeeper 1.4.1 → 1.5.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: 5ab9c1f15bd2dfc3d1baa1f5fb6412269919eea3
4
- data.tar.gz: d1abb98418e1d00648728c1132a9e01dcbed9985
3
+ metadata.gz: cb86c0771b8af2bb376144477a152548c2045c21
4
+ data.tar.gz: aa6f2652e7b62b2b8a926d6b201866c3d1a79d8b
5
5
  SHA512:
6
- metadata.gz: 9f48dcf695400873308dfc8b6afc1afff51e5115c990a5f7ea9787ec26f0be30cb17e0c91a006488fdf208aafe18f44ac11b24a75ce79b099729b978b4b1965e
7
- data.tar.gz: 482c9ad1f3e44ed2172224b7079fe7f525ade1dbf0ed539be6e75c0a3ba7ad0c4a9671dad3bcf71ff904321a3accf7a98864e82ac91b9987acc1edbac35c4990
6
+ metadata.gz: eb18f9197c45fbca068de878cad2e793dc0280abdebb4e3bd275f3cbf8ffd03439bcac110afd232cf8485b611ea72a392e17d7afb663311d1789383467608fc3
7
+ data.tar.gz: a127bb23bcc346fce93614dfff11c054e5b0f2ae5f2da51b058b1b87fb45450773c5030f4ee896dee07c2275cc110a9fef1ffd545c9521bcaa0b12e4d518719c
@@ -1,29 +1,33 @@
1
- # 1.4.1
2
- * Change array creation syntax to support Ruby 1.9
1
+ # 1.5.0
2
+ Adds exception method to simple logger so it can be used as default in
3
+ gems, specs, etc.
3
4
 
4
5
  # 1.4.0
5
- * Adds '_with_data' to the simple logger so we can display data in the terminal
6
- * Adds 'respond_to?' to the multilogger so users can check capabilities of the loggers
6
+ Adds '_with_data' to the simple logger so we can display data in the
7
+ terminal
8
+ Adds 'respond_to?' to the multilogger so users can check capabilities of
9
+ the loggers
7
10
 
8
11
  # 1.3.1
9
- * Loggers provide an inspect method to avoid being too noisy on outputs
12
+ Loggers provide an inspect method to avoid being too noisy on outputs
10
13
 
11
14
  # 1.3.0
12
- * Time in the JSON output specifies microseconds.
13
- * Using 'Z' to specify the UTC timezone instead of +0000 as per ISO 8601.
14
- * Debug and Info messages use the default foreground color of the terminal.
15
+ Time in the JSON output specifies microseconds.
16
+ Using 'Z' to specify the UTC timezone instead of +0000 as per ISO 8601.
17
+ Debug and Info messages use the default foreground color of the terminal.
15
18
 
16
19
  # 1.2.1
17
- * If a file does not exist, it will create it on behalf of the application
20
+ If a file does not exist, it will create it on behalf of the application
18
21
 
19
22
  # 1.2
20
- * Added a silence_logger method to the logger. For compatibility with activerecord-session and maybe other gems.
21
-
23
+ Added a silence_logger method to the logger. For compatibility with
24
+ activerecord-session and maybe other gems.
22
25
  # 1.1.1
23
- * Avoid syntax errors in rubies < 2.3
26
+ Avoid syntax errors in rubies < 2.3
24
27
 
25
28
  # 1.1.0
26
- * Added an 'add' method to the logger so it is compatible with the Logger provided by Ruby's standard library
29
+ Added an 'add' method to the logger so it is compatible with the Logger
30
+ provided by Ruby's standard library
27
31
 
28
32
  # 1.0.0
29
- * Initial release
33
+ Initial release
data/Rakefile CHANGED
@@ -48,6 +48,13 @@ task :benchmark do
48
48
 
49
49
  log = create_logger
50
50
  simple_log = create_simple_logger
51
+ Benchmark.ips do |bm|
52
+ bm.report('short content') { Time.now }
53
+ bm.report('Logger short content') { Time.now.utc }
54
+ bm.report('long content') { Time.now.strftime('%FT%T.%6NZ') }
55
+ bm.report('Logger long content') { Time.now.utc.strftime('%FT%T.%6NZ') }
56
+ bm.compare!
57
+ end
51
58
 
52
59
  Benchmark.ips do |bm|
53
60
  bm.report('short content') { log.error(contents) }
@@ -21,7 +21,7 @@ module Lorekeeper
21
21
  @file = file # We only keep this so we can inspect where we are sending the logs
22
22
  end
23
23
 
24
- LOGGING_METHODS = [:debug, :info, :warn, :error, :fatal]
24
+ LOGGING_METHODS = %i(debug info warn error fatal)
25
25
  METHOD_SEVERITY_MAP = { debug: DEBUG, info: INFO, warn: WARN, error: ERROR, fatal: FATAL }
26
26
 
27
27
  # We define the behaviour of all the usual logging methods
@@ -152,7 +152,19 @@ module Lorekeeper
152
152
  log_data(METHOD_SEVERITY_MAP[method_name], "#{message_param}, data: #{data}")
153
153
  end
154
154
  end
155
- end
156
155
 
156
+ # TODO: move this to fast_logger so we DRY it
157
+ def exception(exception, custom_message = nil, custom_data = nil)
158
+ if exception.is_a?(Exception)
159
+ backtrace = exception.backtrace || []
160
+ message = custom_message || exception.message
161
+ error_with_data("#{exception.class}: #{message}", backtrace.join("\n"))
162
+ else
163
+ log_data(:warning, 'Logger exception called without exception class.')
164
+ error_with_data("#{exception.class}: #{exception.inspect} #{custom_message}", custom_data)
165
+ end
166
+ end
167
+
168
+ end
157
169
 
158
170
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # The comment above will make all strings in a current file frozen
3
3
  module Lorekeeper
4
- VERSION = '1.4.1'.freeze
4
+ VERSION = '1.5.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lorekeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordi Polo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -171,3 +171,4 @@ signing_key:
171
171
  specification_version: 4
172
172
  summary: Very fast JSON logger
173
173
  test_files: []
174
+ has_rdoc: