tlogger 0.25.1 → 0.26.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release_history.yml +4 -0
- data/Gemfile +1 -0
- data/Rakefile +2 -1
- data/lib/tlogger/tlogger.rb +28 -0
- data/lib/tlogger/version.rb +1 -1
- data/lib/tlogger.rb +52 -37
- data/lib/tlogger_helper.rb +45 -0
- data/tlogger.gemspec +3 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ec6d54a4a04d9944c59b9be2d2627d5d412d4e2b8d7ece85f4d4997f1950526
|
4
|
+
data.tar.gz: 4b573188c87f8cf8f9807e761e21653f1877da8b0094339caee6aac09a320ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1e5a354429fa217521bd77993f2e4dc8d228aa9ca0ddfc5c8d7363c21cf21eab46eafde978a406dd5db490e0bc570a701128e44fc1309a358f10b25f373c29
|
7
|
+
data.tar.gz: 54246b70c1a15451430c7e60c67d79ce3d16a36425f5c7088adae3577660ceaae8d03276b94e63945ae9e72342120b6874634ab4c9e1b54c8b99dab8d66808a5
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/tlogger/tlogger.rb
CHANGED
@@ -318,6 +318,34 @@ module Tlogger
|
|
318
318
|
@include_caller = true
|
319
319
|
end
|
320
320
|
|
321
|
+
# detect if the prompt should be to env or file
|
322
|
+
def self.init(out = STDOUT)
|
323
|
+
if is_dev?
|
324
|
+
Tlogger.new(out)
|
325
|
+
else
|
326
|
+
path = ENV["TLOGGER_FILE_PATH"]
|
327
|
+
if path.nil? or path.empty?
|
328
|
+
Tlogger.new(nil)
|
329
|
+
else
|
330
|
+
path = [path] if not path.is_a?(Array)
|
331
|
+
Tlogger.new(*path)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def self.set_dev_mode
|
337
|
+
ENV["TLOGGER_MODE"] = "dev"
|
338
|
+
end
|
339
|
+
|
340
|
+
def self.set_production_mode
|
341
|
+
ENV.delete("TLOGGER_MODE")
|
342
|
+
end
|
343
|
+
|
344
|
+
def self.is_dev?
|
345
|
+
ENV.keys.include?("TLOGGER_MODE") and ENV["TLOGGER_MODE"].downcase == "dev"
|
346
|
+
end
|
347
|
+
|
348
|
+
|
321
349
|
private
|
322
350
|
def format_message(key)
|
323
351
|
# returning args array
|
data/lib/tlogger/version.rb
CHANGED
data/lib/tlogger.rb
CHANGED
@@ -3,6 +3,8 @@ require "tlogger/version"
|
|
3
3
|
require_relative "tlogger/tlogger"
|
4
4
|
require_relative "tlogger/logger_group"
|
5
5
|
|
6
|
+
require_relative 'tlogger_helper'
|
7
|
+
|
6
8
|
#
|
7
9
|
# :nodoc:
|
8
10
|
#
|
@@ -15,48 +17,61 @@ module Tlogger
|
|
15
17
|
::Tlogger::Tlogger.new(*args,&block)
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
if is_dev?
|
21
|
-
new(STDOUT)
|
22
|
-
else
|
23
|
-
c = output_channel
|
24
|
-
new(*c[:path])
|
25
|
-
end
|
20
|
+
def method_missing(mtd, *args, &block)
|
21
|
+
::Tlogger::Tlogger.send(mtd, *args, &block)
|
26
22
|
end
|
23
|
+
end
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
# # detect if the prompt should be to env or file
|
26
|
+
# def init
|
27
|
+
# if is_dev?
|
28
|
+
# new(STDOUT)
|
29
|
+
# else
|
30
|
+
# c = output_channel
|
31
|
+
# new(*c[:path])
|
32
|
+
# end
|
33
|
+
# end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
# def set_dev_mode
|
36
|
+
# ENV["TLOGGER_MODE"] = "dev"
|
37
|
+
# end
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
# def set_production_mode
|
40
|
+
# ENV.delete("TLOGGER_MODE")
|
41
|
+
# end
|
42
|
+
|
43
|
+
# def is_dev?
|
44
|
+
# ENV.keys.include?("TLOGGER_MODE") and ENV["TLOGGER_MODE"].downcase == "dev"
|
45
|
+
# end
|
46
|
+
|
47
|
+
|
48
|
+
# private
|
49
|
+
# def output_channel
|
50
|
+
# out = ENV["TLOGGER_OUT"]
|
51
|
+
# if not out.nil?
|
52
|
+
# case out
|
53
|
+
# when "file"
|
54
|
+
# path = ENV["TLOGGER_OUTPATH"]
|
55
|
+
# if path =~ /,/
|
56
|
+
# { mode: :file, path: path.split(",") }
|
57
|
+
# else
|
58
|
+
# { mode: :file, path: [path] }
|
59
|
+
# end
|
60
|
+
# else
|
61
|
+
# { mode: :file, path: [nil] }
|
62
|
+
# end
|
63
|
+
# else
|
64
|
+
# { mode: :stdio, path: [nil] }
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
#end # class self
|
39
68
|
|
40
|
-
private
|
41
|
-
def output_channel
|
42
|
-
out = ENV["TLOGGER_OUT"]
|
43
|
-
if not out.nil?
|
44
|
-
case out
|
45
|
-
when "file"
|
46
|
-
path = ENV["TLOGGER_OUTPATH"]
|
47
|
-
if path =~ /,/
|
48
|
-
{ mode: :file, path: path.split(",") }
|
49
|
-
else
|
50
|
-
{ mode: :file, path: [path] }
|
51
|
-
end
|
52
|
-
else
|
53
|
-
{ mode: :file, path: [nil] }
|
54
|
-
end
|
55
|
-
else
|
56
|
-
{ mode: :stdio, path: [nil] }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end # class self
|
60
69
|
|
61
70
|
end
|
62
71
|
|
72
|
+
TloggerHelper = Tlogger::TloggerHelper
|
73
|
+
#v = $VERBOSE
|
74
|
+
#$VERBOSE = nil
|
75
|
+
#Tlogger = Tlogger::Tlogger
|
76
|
+
#$VERBOSE = v
|
77
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module Tlogger
|
3
|
+
module TloggerHelper
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def init_tlogger(opts = { })
|
7
|
+
@opts = opts
|
8
|
+
end
|
9
|
+
|
10
|
+
def tlogger
|
11
|
+
if @tlogger.nil?
|
12
|
+
@opts = { } if @opts.nil?
|
13
|
+
defOpts = {
|
14
|
+
tag: nil,
|
15
|
+
dev_mode: false,
|
16
|
+
output: nil
|
17
|
+
}.merge!(@opts)
|
18
|
+
|
19
|
+
Tlogger.set_dev_mode if defOpts[:dev_mode] == true
|
20
|
+
|
21
|
+
if defOpts[:output].nil?
|
22
|
+
@tlogger = Tlogger.init
|
23
|
+
else
|
24
|
+
@tlogger = Tlogger.init(defOpts[:output])
|
25
|
+
end
|
26
|
+
|
27
|
+
@tlogger.tag = tag if not defOpts[:tag].nil? and not defOpts[:tag].empty?
|
28
|
+
end
|
29
|
+
@tlogger
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.included(klass)
|
35
|
+
klass.extend(ClassMethods)
|
36
|
+
end
|
37
|
+
|
38
|
+
def tlogger
|
39
|
+
self.class.tlogger
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
data/tlogger.gemspec
CHANGED
@@ -28,5 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
-
spec.add_development_dependency "devops_helper"
|
31
|
+
#spec.add_development_dependency "devops_helper"
|
32
|
+
spec.add_development_dependency "devops_assist"
|
33
|
+
|
32
34
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: devops_assist
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -34,6 +34,7 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- ".gitignore"
|
37
|
+
- ".release_history.yml"
|
37
38
|
- ".travis.yml"
|
38
39
|
- CODE_OF_CONDUCT.md
|
39
40
|
- Gemfile
|
@@ -45,6 +46,7 @@ files:
|
|
45
46
|
- lib/tlogger/logger_group.rb
|
46
47
|
- lib/tlogger/tlogger.rb
|
47
48
|
- lib/tlogger/version.rb
|
49
|
+
- lib/tlogger_helper.rb
|
48
50
|
- samples/basic.rb
|
49
51
|
- samples/group.rb
|
50
52
|
- tlogger.gemspec
|