tty-logger 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +6 -4
- data/lib/tty/logger.rb +16 -6
- data/lib/tty/logger/handlers/console.rb +2 -2
- data/lib/tty/logger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 708549fdd3524759b7404ed40af85915383fbd0be763133ce06b569931dd776b
|
4
|
+
data.tar.gz: 8279b0f105fb3fe7c04e82a129a898f831c48b1b9141d52532f44270ff431d0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2198bb08a4e783e13910e44934c4d4f7a4eb27c5f724f6d0911acb31f54bac546e239ed04565893ca2993a516924ebba2f6d3a2d00b8ad57e35c4c44db69ecd2
|
7
|
+
data.tar.gz: c89656676101aae012ad6d3cc236deb11fc80dc7e5026be7a64c77bb25917d40425085fb3a906b0d61436c69ef4b3e67c7fc4ad178a60718bdc347918e5327ba
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.6.0] - 2020-12-05
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* Add :enable_color option to control coloring in the console handler
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
* Change #add_handler to accept handler configuration options as an extra parameter
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
* Fix removing handlers by name or type
|
13
|
+
|
3
14
|
## [v0.5.0] - 2020-09-27
|
4
15
|
|
5
16
|
### Added
|
@@ -50,6 +61,7 @@
|
|
50
61
|
|
51
62
|
* Initial implementation and release
|
52
63
|
|
64
|
+
[v0.6.0]: https://github.com/piotrmurach/tty-logger/compare/v0.5.0..v0.6.0
|
53
65
|
[v0.5.0]: https://github.com/piotrmurach/tty-logger/compare/v0.4.0..v0.5.0
|
54
66
|
[v0.4.0]: https://github.com/piotrmurach/tty-logger/compare/v0.3.0..v0.4.0
|
55
67
|
[v0.3.0]: https://github.com/piotrmurach/tty-logger/compare/v0.2.0..v0.3.0
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# TTY::Logger [][gitter]
|
6
6
|
|
7
7
|
[][gem]
|
8
|
-
[][gh_actions_ci]
|
9
9
|
[][appveyor]
|
10
10
|
[][codeclimate]
|
11
11
|
[][coverage]
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
[gitter]: https://gitter.im/piotrmurach/tty
|
15
15
|
[gem]: http://badge.fury.io/rb/tty-logger
|
16
|
-
[
|
16
|
+
[gh_actions_ci]: https://github.com/piotrmurach/tty-logger/actions?query=workflow%3ACI
|
17
17
|
[appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-logger
|
18
18
|
[codeclimate]: https://codeclimate.com/github/piotrmurach/tty-logger
|
19
19
|
[coverage]: https://coveralls.io/github/piotrmurach/tty-logger
|
@@ -549,9 +549,11 @@ logger.remove_handler(:console)
|
|
549
549
|
The console handler prints log messages to the console. It supports the following options:
|
550
550
|
|
551
551
|
* `:styles` - a hash of styling options.
|
552
|
-
* `:formatter` - the formatter for log messages. Defaults to `:text
|
553
|
-
* `:output` - the device to log error messages to. Defaults to `$stderr
|
552
|
+
* `:formatter` - the formatter for log messages. Defaults to `:text`.
|
553
|
+
* `:output` - the device to log error messages to. Defaults to `$stderr`.
|
554
554
|
* `:message_format` - uses `sprintf` format to display messages. Defaults to `"%-25s"`.
|
555
|
+
* `:enable_color` - when `true` forces colored output, when `false` disables colored output.
|
556
|
+
Defaults to `nil` which performs automatic terminal color support detection.
|
555
557
|
|
556
558
|
The supported options in the `:styles` are:
|
557
559
|
|
data/lib/tty/logger.rb
CHANGED
@@ -134,13 +134,22 @@ module TTY
|
|
134
134
|
# @example
|
135
135
|
# add_handler(:console)
|
136
136
|
#
|
137
|
+
# @example
|
138
|
+
# add_handler(:console, styles: { info: { color: :yellow } })
|
139
|
+
#
|
140
|
+
# @example
|
141
|
+
# add_handler([:console, message_format: "%-10s"])
|
142
|
+
#
|
143
|
+
# @param [Symbol, Handlers] handler
|
144
|
+
# the handler name or class
|
145
|
+
#
|
137
146
|
# @api public
|
138
|
-
def add_handler(handler)
|
139
|
-
h,
|
140
|
-
|
147
|
+
def add_handler(handler, **options)
|
148
|
+
h, h_opts = *(handler.is_a?(Array) ? handler : [handler, options])
|
149
|
+
handler_type = coerce_handler(h)
|
141
150
|
global_opts = { output: @output, config: @config }
|
142
|
-
opts = global_opts.merge(
|
143
|
-
ready_handler =
|
151
|
+
opts = global_opts.merge(h_opts)
|
152
|
+
ready_handler = handler_type.new(**opts)
|
144
153
|
@ready_handlers << ready_handler
|
145
154
|
end
|
146
155
|
|
@@ -151,7 +160,8 @@ module TTY
|
|
151
160
|
#
|
152
161
|
# @api public
|
153
162
|
def remove_handler(handler)
|
154
|
-
|
163
|
+
handler_type = coerce_handler(handler)
|
164
|
+
@ready_handlers.delete_if { |_handler| _handler.is_a?(handler_type) }
|
155
165
|
end
|
156
166
|
|
157
167
|
# Coerce handler name into object
|
@@ -82,7 +82,7 @@ module TTY
|
|
82
82
|
attr_reader :message_format
|
83
83
|
|
84
84
|
def initialize(output: $stderr, formatter: nil, config: nil, level: nil,
|
85
|
-
styles: {}, message_format: "%-25s")
|
85
|
+
styles: {}, enable_color: nil, message_format: "%-25s")
|
86
86
|
@output = Array[output].flatten
|
87
87
|
@formatter = coerce_formatter(formatter || config.formatter).new
|
88
88
|
@formatter_name = @formatter.class.name.split("::").last.downcase
|
@@ -91,7 +91,7 @@ module TTY
|
|
91
91
|
@styles = styles
|
92
92
|
@level = level || @config.level
|
93
93
|
@mutex = Mutex.new
|
94
|
-
@pastel = Pastel.new
|
94
|
+
@pastel = Pastel.new(enabled: enable_color)
|
95
95
|
@message_format = message_format
|
96
96
|
end
|
97
97
|
|
data/lib/tty/logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|