cute_logger 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/cute_logger.rb +4 -4
- data/lib/cute_logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d3523a219c949dde0b71ad25bfa5d9829f301ad
|
4
|
+
data.tar.gz: 069937c907681020fd52a82b09b3ff9556b15523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac824f1b4edc95bd93f350c26cd9318d0aa10160ea98e6522b4e641412ed80a701a758f2b3aebfbf5852d8c5086048977c851cebd0092a1a1bc4259f58e37705
|
7
|
+
data.tar.gz: 7472207728297a4a79ccbddaf42e471f71ef4f94e9fe893eb2485e8d8cc31211b8006939ea83b96703f6e155f9616f1135795d942eccfa001d5df39b4f945a98
|
data/README.md
CHANGED
@@ -152,6 +152,19 @@ $ grep "ERROR" application.log | grep "ID000233" | cute_log
|
|
152
152
|
$ grep "WARN" application.log | grep "2017-01" | cute_log
|
153
153
|
```
|
154
154
|
|
155
|
+
### Using environment variables
|
156
|
+
|
157
|
+
It is possible to configure the logging settings via environment variables. For example:
|
158
|
+
|
159
|
+
```bash
|
160
|
+
export CUTE_LOGGER_FILENAME=archive.log
|
161
|
+
export CUTE_LOGGER_SHIFT_AGE=7
|
162
|
+
export CUTE_LOGGER_SHIFT_SIZE=1000000
|
163
|
+
export CUTE_LOGGER_SEVERITY=DEBUG
|
164
|
+
```
|
165
|
+
|
166
|
+
This is the recommended way to configuring the logger settings.
|
167
|
+
|
155
168
|
## Development
|
156
169
|
|
157
170
|
Run `rake test` to run the tests.
|
data/lib/cute_logger.rb
CHANGED
@@ -16,11 +16,11 @@ module CuteLogger
|
|
16
16
|
|
17
17
|
def self.setup(settings = {})
|
18
18
|
@logger = Logger.new(
|
19
|
-
settings[:filename] || 'application.log',
|
20
|
-
settings[:shift_age] || 7,
|
21
|
-
settings[:shift_size] || 1024 * 1024 * 1024 # One gigabyte
|
19
|
+
ENV['CUTE_LOGGER_FILENAME'] || settings[:filename] || 'application.log',
|
20
|
+
ENV['CUTE_LOGGER_SHIFT_AGE'] || settings[:shift_age] || 7,
|
21
|
+
ENV['CUTE_LOGGER_SHIFT_SIZE'] || settings[:shift_size] || 1024 * 1024 * 1024 # One gigabyte
|
22
22
|
)
|
23
|
-
@logger.sev_threshold = severity(settings[:severity])
|
23
|
+
@logger.sev_threshold = severity(ENV['CUTE_LOGGER_SEVERITY'] || settings[:severity])
|
24
24
|
@logger.datetime_format = '%Y-%m-%d %H:%M:%S'
|
25
25
|
@logger.formatter = proc do |severity, datetime, progname, msg|
|
26
26
|
"#{datetime},#{severity},#{Process.pid.to_s(16)},#{Thread.current.object_id.to_s(16)}" \
|
data/lib/cute_logger/version.rb
CHANGED