tiny_log 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_log.rb +9 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b0c929818f43c13ea0abc76b487773fffaa9a41dfc9457260f39d5c53c42de5
4
- data.tar.gz: 782f6be926f8be3420ad06a90df545946a2e94ab5e09a079bbe04d86e6ef20f7
3
+ metadata.gz: 15005e17d6f5c9e590ad8068d114a838e6cb3e7a89a0cd4d79198996d53f0a7f
4
+ data.tar.gz: ccd7c0a3ae7f80550055465e436d8b7ebce4ffab922ead8fff8f886373b8b15a
5
5
  SHA512:
6
- metadata.gz: e7fcaeb0db49141f2a37c1619146564541ff4457db10aebc1a68470865bf669d98d355e9194cada4c47614e0ee52c35063a92a2218b756c21cf6eb0cc16d7409
7
- data.tar.gz: 6893fd027e3d9b7443216385ab4e04169d1c55447af72ee8d7a64ec052356b2af336364859af47362e237f66ce73dc8b384c8e242ba405e954e555282af47fce
6
+ metadata.gz: 17d8cad422dce69112a591b170cfe5d4d5ddaf4e8d421466426d5fe01f4b5a0cf0acb3970baeaa170957c1274af2ca42715fd0c4513fc6521febdc1b24664946
7
+ data.tar.gz: 8b97be546678bb91417410004a64c41885b6e83b49c942d50389095d809b6a3c1a886870db08e1d7f3087564c06400e899f250c51a7107c1deb49d20ec967ced
data/lib/tiny_log.rb CHANGED
@@ -16,8 +16,13 @@ class TinyLog
16
16
  # filename: the I/O stream to send log messages to
17
17
  # if unspecified, will default to $stdout
18
18
  # if specified, attempts to open a file with the specified name to append to
19
- def initialize(filename=nil)
20
- @io = filename ? File.open(filename, 'a') : $stdout
19
+ # buffered: whether or not to buffer log output
20
+ # true, or not specified: log buffering is enabled
21
+ # false: log buffering is disabled - most useful for dev/test environments
22
+ # where you want to watch output in realtime
23
+ def initialize(filename=nil, buffering=true)
24
+ @buffering = !!buffering
25
+ @io = filename.is_a?(String) ? File.open(filename, 'a') : $stdout
21
26
  end
22
27
 
23
28
  # the clever bit that annotates the log message with a log level and UTC
@@ -29,6 +34,8 @@ class TinyLog
29
34
  end
30
35
  end
31
36
 
37
+ @io.flush unless @buffering
38
+
32
39
  nil
33
40
  end
34
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
11
+ date: 2022-11-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a tiny logger with almost no features
14
14
  email: jefflunt@gmail.com