console 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/console/terminal/logger.rb +24 -4
- data/lib/console/version.rb +1 -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: a8cd747edadd12f8a9c8f01538e8e89986cb5ac6632d743f8ca4280c18166dba
|
4
|
+
data.tar.gz: 4c6eb9b8ebd974af8eac9ecf7db5ac9a7998fcc8116468a0a81a4cb1b317063a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acd069d149e295163cf2bdf8a45b12d72ec77c677b988e0e0554fb789bf724d09284c48e181dc6927cf5590a81ac69f9e442dc186bb4caf371fac6675e0e34c8
|
7
|
+
data.tar.gz: 8dc2fd1bd53a653e26190b8a818a25c80b50482eec4e2d44a572897199530ea5265349f1d3fe616cf34797f222516d1957b15ac256882ea631e708c687d74e51
|
data/.travis.yml
CHANGED
@@ -26,6 +26,23 @@ require_relative 'xterm'
|
|
26
26
|
|
27
27
|
module Console
|
28
28
|
module Terminal
|
29
|
+
# This, and all related methods, is considered private.
|
30
|
+
CONSOLE_START_AT = 'CONSOLE_START_AT'
|
31
|
+
|
32
|
+
# Exports CONSOLE_START which can be used to synchronize the start times of all child processes when they log using delta time.
|
33
|
+
def self.start_at!(environment = ENV)
|
34
|
+
if time_string = environment[CONSOLE_START_AT]
|
35
|
+
start_at = Time.parse(time_string) rescue nil
|
36
|
+
end
|
37
|
+
|
38
|
+
unless start_at
|
39
|
+
start_at = Time.now
|
40
|
+
environment[CONSOLE_START_AT] = start_at.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
return start_at
|
44
|
+
end
|
45
|
+
|
29
46
|
def self.for(io)
|
30
47
|
if io.isatty
|
31
48
|
XTerm.new(io)
|
@@ -35,9 +52,9 @@ module Console
|
|
35
52
|
end
|
36
53
|
|
37
54
|
class Logger
|
38
|
-
def initialize(io = $stderr, verbose: nil, **options)
|
55
|
+
def initialize(io = $stderr, verbose: nil, start_at: Terminal.start_at!, **options)
|
39
56
|
@io = io
|
40
|
-
@
|
57
|
+
@start_at = start_at
|
41
58
|
|
42
59
|
@terminal = Terminal.for(io)
|
43
60
|
|
@@ -49,6 +66,7 @@ module Console
|
|
49
66
|
|
50
67
|
@terminal[:logger_prefix] ||= @terminal.style(nil, nil, nil)
|
51
68
|
@terminal[:logger_suffix] ||= @terminal.style(:white, nil, :faint)
|
69
|
+
@terminal[:subject] ||= @terminal.style(nil, nil, :bold)
|
52
70
|
@terminal[:debug] = @terminal.style(:cyan)
|
53
71
|
@terminal[:info] = @terminal.style(:green)
|
54
72
|
@terminal[:warn] = @terminal.style(:yellow)
|
@@ -121,7 +139,9 @@ module Console
|
|
121
139
|
suffix = " #{@terminal[:logger_suffix]}[pid=#{Process.pid}] [#{Time.now}]#{@terminal.reset}"
|
122
140
|
end
|
123
141
|
|
124
|
-
|
142
|
+
prefix = "#{prefix_style}#{prefix}:#{@terminal.reset} "
|
143
|
+
|
144
|
+
output.puts "#{@terminal[:subject]}#{subject}#{@terminal.reset}#{suffix}", prefix: prefix
|
125
145
|
end
|
126
146
|
|
127
147
|
def format_value(value, output)
|
@@ -133,7 +153,7 @@ module Console
|
|
133
153
|
end
|
134
154
|
|
135
155
|
def time_offset_prefix
|
136
|
-
offset = Time.now - @
|
156
|
+
offset = Time.now - @start_at
|
137
157
|
minutes = (offset/60).floor
|
138
158
|
seconds = (offset - (minutes*60))
|
139
159
|
|
data/lib/console/version.rb
CHANGED
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.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: covered
|