lite_logger 0.1.8 → 0.1.9
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 +5 -0
- data/README.md +54 -9
- data/lib/lite_logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d602a3b8fc99ae133103a80f0433ae75b108c71cf09e4a139bc46ba3cc4476da
|
|
4
|
+
data.tar.gz: 200bc83513a92bf88b7a95b57f1a89e86847b20717e83a097fdc417577652224
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c0328c6b5214b05f823f526d4d8228028b2ed2e3c2398efe54c4e8366927d7196ae4051ed03d29b08f5c932b8938f949df81f5219118e9c1dde38e167459d53
|
|
7
|
+
data.tar.gz: 5839ca20af83326d06e0f98923de9f217148fd8d399bc57d1f378654e57b288702a84d5e0793c5e102a137bed1eba9c6e4752aec8608214b54098e7b82d68da6
|
data/CHANGELOG.md
CHANGED
|
@@ -46,3 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
46
46
|
- Add optional custom formatter support for application-specific log output.
|
|
47
47
|
- Create parent directories automatically when logging to a file destination.
|
|
48
48
|
- Move development tools out of runtime dependencies.
|
|
49
|
+
|
|
50
|
+
## [0.1.9] - 2026-03-29
|
|
51
|
+
|
|
52
|
+
- Expand the spec suite around global configuration, formatter errors, JSON timestamps, and append behavior.
|
|
53
|
+
- Refresh the README with examples for file logging, JSON output, custom formatters, and global configuration.
|
data/README.md
CHANGED
|
@@ -28,17 +28,15 @@ gem install lite_logger
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
###
|
|
31
|
+
### Basic example
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
In a Ruby class:
|
|
34
34
|
|
|
35
35
|
```ruby
|
|
36
|
-
# Require the gem
|
|
37
36
|
require 'lite_logger'
|
|
38
37
|
|
|
39
38
|
class MyClass
|
|
40
39
|
def initialize
|
|
41
|
-
# Initialize the logger
|
|
42
40
|
@logger = LiteLogger::Logger.new
|
|
43
41
|
end
|
|
44
42
|
|
|
@@ -49,19 +47,18 @@ class MyClass
|
|
|
49
47
|
@logger.error('This is an error message')
|
|
50
48
|
@logger.fatal('This is a fatal message')
|
|
51
49
|
|
|
52
|
-
# [...]
|
|
53
50
|
end
|
|
54
51
|
end
|
|
55
52
|
```
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
### Logging to a file
|
|
58
55
|
|
|
59
56
|
```ruby
|
|
60
57
|
require 'lite_logger'
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
logger = LiteLogger::Logger.new
|
|
60
|
+
logger.destination = './log/application.log'
|
|
61
|
+
logger.info('Application started!')
|
|
65
62
|
```
|
|
66
63
|
|
|
67
64
|
Output:
|
|
@@ -70,6 +67,54 @@ Output:
|
|
|
70
67
|
2024-07-10 18:58:07 -0300 [INFO] Application started!
|
|
71
68
|
```
|
|
72
69
|
|
|
70
|
+
Parent directories are created automatically when the destination is a file path.
|
|
71
|
+
|
|
72
|
+
### JSON output
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
require 'lite_logger'
|
|
76
|
+
|
|
77
|
+
logger = LiteLogger::Logger.new
|
|
78
|
+
logger.format = :json
|
|
79
|
+
logger.info('Application started!')
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Example output:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{"level":"info","message":"Application started!","timestamp":"2026-03-29 21:00:00 -0300"}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Custom formatter
|
|
89
|
+
|
|
90
|
+
Use `formatter` when you need full control over the rendered log line.
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
require 'lite_logger'
|
|
94
|
+
require 'time'
|
|
95
|
+
|
|
96
|
+
logger = LiteLogger::Logger.new
|
|
97
|
+
logger.destination = './log/custom.log'
|
|
98
|
+
logger.formatter = lambda do |level, message, time|
|
|
99
|
+
"[#{time.iso8601}] #{level.upcase}: #{message}"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
logger.info('Application started!')
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Global configuration
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
require 'lite_logger'
|
|
109
|
+
|
|
110
|
+
LiteLogger.configure do |logger|
|
|
111
|
+
logger.level = :debug
|
|
112
|
+
logger.destination = './log/application.log'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
LiteLogger.logger.info('Application started!')
|
|
116
|
+
```
|
|
117
|
+
|
|
73
118
|
## Contributing
|
|
74
119
|
|
|
75
120
|
Bug reports and pull requests are welcome: <https://github.com/dmferrari/lite_logger/pulls>.
|
data/lib/lite_logger/version.rb
CHANGED