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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2097702e7fcefd385c55d485f0ef8f26c16b6a4f523064be6f05e497ae510b5
4
- data.tar.gz: 295a7c220f3df575dd88c6062bf1c6f77a6f902122dc5adba06b86481b268df6
3
+ metadata.gz: 6516c4c850abccb0dc4817269e14c96e292ecd1c5f02fbc23cba7b68912b7386
4
+ data.tar.gz: 3b02e0e685bfacd43a0c5fa234c5f65d99284480bba721f433e9978416212c5d
5
5
  SHA512:
6
- metadata.gz: ca42907248b81dc572c21475b7db339d2f3caaa017854f0b9af465f7950b524a270180f7dcae7572f96b5f97ce08060f9083809c5620884e56860883c4583cf8
7
- data.tar.gz: c8f1fe748c293b53cbe30c540b591cfc6c23ea9323ec65420d3f2f2c4be40910ba1ba423b0950d81ebfd86d3bd9f775dd642f1680302448b6822e915e34a59a1
6
+ metadata.gz: ced3234b56f358edb9c3c9dc22e96d299965a1dab7d4105bc40be9dcae1f9e6bbcbdd06d9a573cf1105933e938a40edd114a65370cf6279e8c9640f5aeaa9bb0
7
+ data.tar.gz: f351183bc2b81bc2062c1479acb25b16a9fb63451a9d029b57457de8a92509ad39c7599e275d75c66ff94bc49263859e1d9f86f6c6e3b93716e6ade0a1c84520
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
  /tmp/
9
9
 
10
10
  *.log
11
+ *.gem
12
+ Gemfile.lock
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
+ require 'devops_helper'
5
+
4
6
  Rake::TestTask.new(:test) do |t|
5
7
  t.libs << "test"
6
8
  t.libs << "lib"
@@ -1,3 +1,3 @@
1
1
  module Tlogger
2
- VERSION = "0.22.0"
2
+ VERSION = "0.26.1"
3
3
  end
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
@@ -27,4 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.bindir = "exe"
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "devops_helper"
30
32
  end
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.22.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: 2020-10-13 00:00:00.000000000 Z
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.1.4
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