tlogger 0.22.0 → 0.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Rakefile +2 -0
- data/lib/tlogger/version.rb +1 -1
- data/lib/tlogger.rb +46 -1
- data/lib/tlogger_helper.rb +35 -0
- data/tlogger.gemspec +2 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6516c4c850abccb0dc4817269e14c96e292ecd1c5f02fbc23cba7b68912b7386
|
4
|
+
data.tar.gz: 3b02e0e685bfacd43a0c5fa234c5f65d99284480bba721f433e9978416212c5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ced3234b56f358edb9c3c9dc22e96d299965a1dab7d4105bc40be9dcae1f9e6bbcbdd06d9a573cf1105933e938a40edd114a65370cf6279e8c9640f5aeaa9bb0
|
7
|
+
data.tar.gz: f351183bc2b81bc2062c1479acb25b16a9fb63451a9d029b57457de8a92509ad39c7599e275d75c66ff94bc49263859e1d9f86f6c6e3b93716e6ade0a1c84520
|
data/Rakefile
CHANGED
data/lib/tlogger/version.rb
CHANGED
data/lib/tlogger.rb
CHANGED
@@ -8,13 +8,58 @@ require_relative "tlogger/logger_group"
|
|
8
8
|
#
|
9
9
|
module Tlogger
|
10
10
|
class Error < StandardError; end
|
11
|
-
|
11
|
+
|
12
12
|
# shorten the initializer to Tlogger.new instead of the longer Tlogger::Tlogger.new
|
13
13
|
class << self
|
14
14
|
def new(*args,&block)
|
15
15
|
::Tlogger::Tlogger.new(*args,&block)
|
16
16
|
end
|
17
|
+
|
18
|
+
# detect if the prompt should be to env or file
|
19
|
+
def init
|
20
|
+
if is_dev?
|
21
|
+
new(STDOUT)
|
22
|
+
else
|
23
|
+
c = output_channel
|
24
|
+
new(*c[:path])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_dev_mode
|
29
|
+
ENV["TLOGGER_MODE"] = "dev"
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_production_mode
|
33
|
+
ENV.delete("TLOGGER_MODE")
|
34
|
+
end
|
35
|
+
|
36
|
+
def is_dev?
|
37
|
+
ENV.keys.include?("TLOGGER_MODE") and ENV["TLOGGER_MODE"].downcase == "dev"
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
def output_channel
|
43
|
+
out = ENV["TLOGGER_OUT"]
|
44
|
+
if not out.nil?
|
45
|
+
case out
|
46
|
+
when "file"
|
47
|
+
path = ENV["TLOGGER_OUTPATH"]
|
48
|
+
if path =~ /,/
|
49
|
+
{ mode: :file, path: path.split(",") }
|
50
|
+
else
|
51
|
+
{ mode: :file, path: [path] }
|
52
|
+
end
|
53
|
+
else
|
54
|
+
{ mode: :file, path: [nil] }
|
55
|
+
end
|
56
|
+
else
|
57
|
+
{ mode: :stdio, path: [nil] }
|
58
|
+
end
|
59
|
+
end
|
17
60
|
end # class self
|
18
61
|
|
62
|
+
|
19
63
|
end
|
20
64
|
|
65
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
require_relative 'tlogger'
|
3
|
+
|
4
|
+
module Tlogger
|
5
|
+
module TloggerHelper
|
6
|
+
|
7
|
+
module TloggerClassMethods
|
8
|
+
def tlogger(tag = nil)
|
9
|
+
if @tlogger.nil?
|
10
|
+
@tlogger = ::Tlogger.init
|
11
|
+
@tlogger.tag = tag if not (tag.nil? and tag.empty?)
|
12
|
+
end
|
13
|
+
@tlogger
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_logger(tag, dev_mode = false)
|
17
|
+
::Tlogger.set_dev_mode if dev_mode
|
18
|
+
tlogger(tag)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(klass)
|
23
|
+
klass.extend(TloggerClassMethods)
|
24
|
+
end
|
25
|
+
|
26
|
+
self.extend(TloggerClassMethods)
|
27
|
+
|
28
|
+
if not respond_to?(:logger)
|
29
|
+
def logger
|
30
|
+
self.class.tlogger
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/tlogger.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: devops_helper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Logger that provides some control over how the log messages are being
|
14
28
|
displayed with conditionally enable and disable certain log messages from showing
|
15
29
|
based on configurations
|
@@ -31,6 +45,7 @@ files:
|
|
31
45
|
- lib/tlogger/logger_group.rb
|
32
46
|
- lib/tlogger/tlogger.rb
|
33
47
|
- lib/tlogger/version.rb
|
48
|
+
- lib/tlogger_helper.rb
|
34
49
|
- samples/basic.rb
|
35
50
|
- samples/group.rb
|
36
51
|
- tlogger.gemspec
|
@@ -54,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
69
|
- !ruby/object:Gem::Version
|
55
70
|
version: '0'
|
56
71
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
72
|
+
rubygems_version: 3.2.22
|
58
73
|
signing_key:
|
59
74
|
specification_version: 4
|
60
75
|
summary: Logger that added contextual information to the log messages
|