uu 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: 8b7321eb0a2d0928bc20c2ee316c730243f3cb10b1fe4eda29d18d4d6507a81a
4
- data.tar.gz: cedd60c4e5b0606e31e7f2aec8fe6db9dd426f00cf2c8d8e768d52a6268e0d58
3
+ metadata.gz: 14e1e3bf983702c4482517b7e01bd949137b9bd6c3ac9ec8b98e44115554384f
4
+ data.tar.gz: fdaa6b2c59fdd914b619ca25be38b461b6d32fca643a060dae4c78d186b0459a
5
5
  SHA512:
6
- metadata.gz: 99a5ff6fc748b2f6632f76f987f53130127c427a81ad1ff4d92fbede3fb989703e6e19d15cfcdb3391455cf5a27b8d8be9fd4c7c4b1fe2a1778200175e310ce8
7
- data.tar.gz: 2a48f11663da10487d6be1cc117dbb09add2325a5056c169684dc4d0fdaf6011ab1eb7cb2507dcaf07d00d822224e88805da8dc612f2d6fa3a4941ae95fb4796
6
+ metadata.gz: e8fc6f3aa6358952c58841d8fd7d421f32801a57fdf048735fff98688e8857d803088db17f9d60024b57237237611458dd35e28e00e70e0640bdb4693a8e5255
7
+ data.tar.gz: 21365178ae087e6f1b2e793b9e8b59b2609adc1c58aed2d4aaf936184fab5c5f582c2f66edf30b00dc314c11e4ba36731be5d17bbeed2581235818738388b693
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uu (0.2.1)
4
+ uu (0.2.2)
5
5
  colorize
6
6
  fluent-logger
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  diff-lcs (1.3)
16
16
  dotenv (2.6.0)
17
17
  ffi (1.10.0)
18
- fluent-logger (0.7.2)
18
+ fluent-logger (0.8.0)
19
19
  msgpack (>= 1.0.0, < 2)
20
20
  formatador (0.2.5)
21
21
  guard (2.15.0)
@@ -120,4 +120,4 @@ DEPENDENCIES
120
120
  yard
121
121
 
122
122
  BUNDLED WITH
123
- 1.17.2
123
+ 2.0.1
@@ -7,15 +7,6 @@ require 'json'
7
7
  module UU
8
8
  class LoggerStderr < Logger
9
9
  class Formatter
10
- DECORATION = {
11
- 'UNKNOWN' => { color: :red, mode: :underline },
12
- 'FATAL' => { color: :red, mode: :underline },
13
- 'ERROR' => :red,
14
- 'WARN' => :yellow,
15
- 'INFO' => :default,
16
- 'DEBUG' => :light_black,
17
- }.freeze
18
-
19
10
  def initialize(context)
20
11
  @context = context
21
12
  end
@@ -32,7 +23,7 @@ module UU
32
23
  "#{short_severity}]#{time_format}" \
33
24
  "[#{loc[:filename]}##{loc[:method]}:#{loc[:lineno]}] " \
34
25
  "#{context_msg}" \
35
- "#{msg}\n".colorize(DECORATION[severity])
26
+ "#{msg}\n"
36
27
  end
37
28
 
38
29
  def meaningful_location
@@ -59,8 +50,24 @@ module UU
59
50
  end
60
51
  end
61
52
 
53
+ class FormatterColor < Formatter
54
+ DECORATION = {
55
+ 'UNKNOWN' => { color: :red, mode: :underline },
56
+ 'FATAL' => { color: :red, mode: :underline },
57
+ 'ERROR' => :red,
58
+ 'WARN' => :yellow,
59
+ 'INFO' => :default,
60
+ 'DEBUG' => :light_black,
61
+ }.freeze
62
+
63
+ def call(severity, time, _progname, msg)
64
+ super.colorize(DECORATION[severity])
65
+ end
66
+ end
67
+
62
68
  def initialize(context)
63
- super($stderr, formatter: Formatter.new(context))
69
+ formatter = $stderr.tty? ? FormatterColor : Formatter
70
+ super($stderr, formatter: formatter.new(context))
64
71
  end
65
72
  end
66
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UU
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minwoo Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize