console 1.1.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 905a0b4a1dc6fc5ce11e3c8ddb2cddf17ea280cb8e59fec936e314e82cea8b6f
4
- data.tar.gz: dc1bbe02f4e974fbec84385b2214f8ad27e8f2cd9cdeaf683bbe96645c613161
3
+ metadata.gz: bded8af5dd4c678a7dd209c062f622d55cac4645bb490b9e7484a7bea9a7b688
4
+ data.tar.gz: a80bdc503770d93315d3fa4341d12cfa1f27a57b8eab5296d7c67db8057a906a
5
5
  SHA512:
6
- metadata.gz: 73dc76f42e3249c3ead06056dedef0e0eb37025f5389d14e200852a6a9355b7d968694090bdee8000f34f48241fbe90ebef45a4081b2949189adff16d977d5aa
7
- data.tar.gz: 7f4a918850a457ff12de55006854cbc068b8cbd3a02a239e7587d9d64424cfcfffebd24400f3a12b1d5cd28b4140a6cd2c23bdd328a6ef4acd40bc9002384273
6
+ metadata.gz: f2744fbc53ee930f47123d0d4b01262ef1e7518c50bf718a7f10edd1de669fac75c9104d30eb7aaf1d42fe970f2a6013315cf2ba45a352375ee851301274b955
7
+ data.tar.gz: 27a0143476c5368c276baa69b8498d26a29dd3c8cdc92d6f341255d4039d5a9bcd3b5b8c35024ef3108fb5e778d429671327d1158bc356fac72f58d70502aac1
data/README.md CHANGED
@@ -91,15 +91,13 @@ end
91
91
  Console.logger.info("My Console", MyConsole.new)
92
92
  ```
93
93
 
94
- #### Error Events
94
+ #### Failure Events
95
95
 
96
- `Console::Error` represents an error and will log the message and backtrace recursively.
96
+ `Console::Event::Failure` represents an exception and will log the message and backtrace recursively.
97
97
 
98
- #### Shell Events
98
+ #### Spawn Events
99
99
 
100
- `Console::Shell` represents the execution of a shell command, and will log the environment, arguments and options used to execute it.
101
-
102
- ### Multiple Loggers
100
+ `Console::Event::Spawn` represents the execution of a command, and will log the environment, arguments and options used to execute it.
103
101
 
104
102
  ### Custom Log Levels
105
103
 
@@ -118,6 +116,8 @@ logger.broken("It's so janky.")
118
116
 
119
117
  ### Multiple Outputs
120
118
 
119
+ Use `Console::Split` to log to multiple destinations.
120
+
121
121
  ```ruby
122
122
  require 'console/terminal'
123
123
  require 'console/serialized/logger'
@@ -125,13 +125,30 @@ require 'console/logger'
125
125
  require 'console/split'
126
126
 
127
127
  terminal = Console::Terminal::Logger.new
128
- file = Console::Serialized::Logger.new(File.open("/tmp/log.json", "w"))
128
+ file = Console::Serialized::Logger.new(File.open("log.json", "a"))
129
129
 
130
130
  logger = Console::Logger.new(Console::Split[terminal, file])
131
131
 
132
132
  logger.info "I can go everywhere!"
133
133
  ```
134
134
 
135
+ ### Custom Logger Output
136
+
137
+ `Console::Logger` provides a default interface which is a drop in replacemnet for `Logger` and other similar implementations. The only method required for output is `#call(*arguments, **options, &block)`.
138
+
139
+ ```ruby
140
+ require 'console/logger'
141
+
142
+ output = proc do |*arguments, **options, &block|
143
+ puts "arguments: #{arguments.inspect} options: #{options.inspect} block: #{block.call}"
144
+ end
145
+
146
+ logger = Console::Logger.new(output)
147
+
148
+ logger.info("Hello World!", meta: "data") {"block"}
149
+ # => arguments: ["Hello World!"] options: {:severity=>:info, :meta=>"data"} block: block
150
+ ```
151
+
135
152
  ## Contributing
136
153
 
137
154
  1. Fork it
@@ -34,11 +34,11 @@ module Console
34
34
  levels.each do |name, level|
35
35
  const_set(name.to_s.upcase, level)
36
36
 
37
- define_method(name) do |subject = nil, *arguments, &block|
37
+ define_method(name) do |subject = nil, *arguments, **options, &block|
38
38
  enabled = @subjects[subject.class]
39
39
 
40
40
  if enabled == true or (enabled != false and level >= @level)
41
- self.call(subject, *arguments, severity: name, **@options, &block)
41
+ self.call(subject, *arguments, severity: name, **options, **@options, &block)
42
42
  end
43
43
  end
44
44
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Console
22
- VERSION = "1.1.1"
22
+ VERSION = "1.2.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.0.2
118
+ rubygems_version: 3.0.3
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: Beautiful logging for Ruby.