hubbado-log 1.0.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 +4 -4
- data/ChangeLog.md +19 -0
- data/README.md +35 -1
- data/hubbado-log.gemspec +1 -1
- data/lib/hubbado/log/configuration.rb +17 -1
- data/lib/hubbado/log/log.rb +9 -2
- data/lib/hubbado/log/logger.rb +11 -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: 420feafe971a2416372391df56971288d2a8a6730d5b2a5b010370465fe0eecb
|
|
4
|
+
data.tar.gz: 1755fdec20e188020cc6b55431c5a6ccc5edeaec13d952430663e3eb9397685c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1195dd74d23e42ab83a6b93daba36cdd53b5311ee2a1dd19399f1090fe9c2fba4a2b9fe660489a2ba8c85816a3995e495979a7ea3b01c83693a5a2a7dfa0292
|
|
7
|
+
data.tar.gz: a4c8a344ae3c7297037890633fbec484f5d45114cbc2b1f76bdf15314d2b48a5b7b17ad35c6601a9f59720b6ea98c41b9c34676a1d01d5953bbba8ba5627271b
|
data/ChangeLog.md
CHANGED
|
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# [1.2.0 - 2026-08-14]
|
|
8
|
+
## Added
|
|
9
|
+
- A `trace` level, below `debug`. Program flow — a line per iteration of a loop —
|
|
10
|
+
so that turning on the completion of secondary operations does not also turn on
|
|
11
|
+
a line per item in a set.
|
|
12
|
+
|
|
13
|
+
# [1.1.0 - 2026-08-14]
|
|
14
|
+
## Added
|
|
15
|
+
- A level, below which a line reaches no handler. Set it with `config.level`, or
|
|
16
|
+
with the `LOG_LEVEL` environment variable, which defaults to `info` — so
|
|
17
|
+
`debug` is off unless it is asked for.
|
|
18
|
+
|
|
19
|
+
## Changed
|
|
20
|
+
- `Logger.new` takes a `level:` keyword. A logger built without one follows the
|
|
21
|
+
configuration.
|
|
22
|
+
- `LOG_LEVEL` is shared with Eventide's log gem, which writes names this gem does
|
|
23
|
+
not know. A name that is not a severity leaves the level at `info` rather than
|
|
24
|
+
raising.
|
|
25
|
+
|
|
7
26
|
# [1.0.1 - 2024-05-30]
|
|
8
27
|
# Changed
|
|
9
28
|
- Release to stop a SHA mismatch between our private github package repo and Ruby Gems
|
data/README.md
CHANGED
|
@@ -16,7 +16,41 @@ And then execute:
|
|
|
16
16
|
|
|
17
17
|
Or install it yourself as:
|
|
18
18
|
|
|
19
|
-
$ gem install hubbado-
|
|
19
|
+
$ gem install hubbado-log
|
|
20
|
+
|
|
21
|
+
## Level
|
|
22
|
+
|
|
23
|
+
A line below the level reaches no handler.
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
Hubbado::Log.configuration do |config|
|
|
27
|
+
config.loggers = [MyStderrHandler]
|
|
28
|
+
config.level = :debug
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Without `config.level`, the level comes from the `LOG_LEVEL` environment variable:
|
|
33
|
+
|
|
34
|
+
$ LOG_LEVEL=debug ./my-command
|
|
35
|
+
|
|
36
|
+
It defaults to `info`, so `debug` and `trace` are off until they are asked for.
|
|
37
|
+
|
|
38
|
+
Levels, lowest first:
|
|
39
|
+
|
|
40
|
+
| Level | What it records |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `trace` | Most detailed tracing of program flow |
|
|
43
|
+
| `debug` | Completion of a secondary operation of a class or utility, or other details |
|
|
44
|
+
| `info` | Completion of the principal operation of a class or utility |
|
|
45
|
+
| `warn` | Unexpected state that is not an error, or is recoverable, and that a developer or operator should examine |
|
|
46
|
+
| `error` | Message logged just prior to raising an error |
|
|
47
|
+
| `fatal` | Message recorded, when possible, as the process is terminating due to an error |
|
|
48
|
+
A single logger can
|
|
49
|
+
name its own with `Hubbado::Log::Logger.new(subject, handlers, level: :debug)`.
|
|
50
|
+
|
|
51
|
+
`LOG_LEVEL` is shared with Eventide's log gem, which writes names this gem does not
|
|
52
|
+
know. A name that is not one of `debug`, `info`, `warn`, `error`, `fatal` or
|
|
53
|
+
`unknown` leaves the level at `info` rather than raising.
|
|
20
54
|
|
|
21
55
|
## Development
|
|
22
56
|
|
data/hubbado-log.gemspec
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
module Hubbado
|
|
2
2
|
class Log
|
|
3
3
|
class Configuration
|
|
4
|
+
# Tracing is off until somebody asks for it, which is what lets a debug line be written
|
|
5
|
+
# for a human watching one run without it also reaching every unattended log.
|
|
6
|
+
DEFAULT_LEVEL = :info
|
|
7
|
+
|
|
4
8
|
attr_accessor :loggers
|
|
9
|
+
attr_reader :level
|
|
5
10
|
|
|
6
|
-
def initialize
|
|
11
|
+
def initialize(level: nil)
|
|
7
12
|
@loggers = []
|
|
13
|
+
self.level = level || DEFAULT_LEVEL
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# A name rather than a severity is answered with the default instead of an exception.
|
|
17
|
+
# The level is set from LOG_LEVEL, which Eventide's log gem owns across hubbado_saas and
|
|
18
|
+
# writes its own vocabulary into ("_min"): a variable this gem shares is not a variable
|
|
19
|
+
# it can refuse.
|
|
20
|
+
def level=(value)
|
|
21
|
+
named = value.to_s.downcase.to_sym
|
|
22
|
+
|
|
23
|
+
@level = SEVERITIES.key?(named) ? named : DEFAULT_LEVEL
|
|
8
24
|
end
|
|
9
25
|
end
|
|
10
26
|
end
|
data/lib/hubbado/log/log.rb
CHANGED
|
@@ -2,10 +2,17 @@ module Hubbado
|
|
|
2
2
|
class Log
|
|
3
3
|
include Dependency
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Ordered, because the level compares against them. `trace` is program flow, a line per
|
|
6
|
+
# iteration; `debug` is the completion of a secondary operation, or a detail worth keeping;
|
|
7
|
+
# `info` is the completion of the principal operation of a class or utility.
|
|
8
|
+
SEVERITIES = { trace: 0, debug: 1, info: 2, warn: 3, error: 4, fatal: 5, unknown: 6 }.freeze
|
|
6
9
|
STACKTRACE_SEVERITIES = %i[warn error fatal unknown].freeze
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
LEVEL_VARIABLE = "LOG_LEVEL".freeze
|
|
12
|
+
|
|
13
|
+
# The one place the environment is read. A command names its level here or not at all,
|
|
14
|
+
# and everything downstream is handed the value rather than the variable.
|
|
15
|
+
@config = Configuration.new(level: ENV[LEVEL_VARIABLE])
|
|
9
16
|
|
|
10
17
|
class << self
|
|
11
18
|
attr_reader :config
|
data/lib/hubbado/log/logger.rb
CHANGED
|
@@ -4,16 +4,26 @@ module Hubbado
|
|
|
4
4
|
attr_accessor :log_handlers
|
|
5
5
|
attr_accessor :subject
|
|
6
6
|
|
|
7
|
-
def initialize(subject, log_handlers = [])
|
|
7
|
+
def initialize(subject, log_handlers = [], level: nil)
|
|
8
8
|
self.subject = subject
|
|
9
9
|
self.log_handlers = Array(log_handlers)
|
|
10
|
+
@level = level
|
|
10
11
|
end
|
|
11
12
|
|
|
13
|
+
# A logger built without one follows the configuration, which is every logger the gem
|
|
14
|
+
# builds itself: `Log.configure` names no level, so a class using the Dependency module
|
|
15
|
+
# takes whatever the process was configured for.
|
|
16
|
+
def level = @level || Log.config.level
|
|
17
|
+
|
|
12
18
|
def log(severity, msg, data = nil)
|
|
13
19
|
unless SEVERITIES.keys.include? severity.to_sym
|
|
14
20
|
raise ArgumentError, "Unknown serverity #{severity}"
|
|
15
21
|
end
|
|
16
22
|
|
|
23
|
+
# Read after the severity is checked, never before: the level decides what is printed,
|
|
24
|
+
# not what may be said, so quietening a logger must not turn a typo into silence.
|
|
25
|
+
return if SEVERITIES.fetch(severity.to_sym) < SEVERITIES.fetch(level)
|
|
26
|
+
|
|
17
27
|
stacktrace = if data.is_a?(Exception)
|
|
18
28
|
data.full_message
|
|
19
29
|
elsif STACKTRACE_SEVERITIES.include?(severity)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hubbado-log
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hubbado Devs
|
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
108
|
version: '0'
|
|
109
109
|
requirements: []
|
|
110
|
-
rubygems_version:
|
|
110
|
+
rubygems_version: 4.0.6
|
|
111
111
|
specification_version: 4
|
|
112
112
|
summary: Lightweight pluggable logging system
|
|
113
113
|
test_files: []
|