tlogger 0.6.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/README.md +91 -9
- data/Rakefile +9 -1
- data/bin/console +4 -4
- data/lib/tlogger.rb +11 -309
- data/lib/tlogger/logger_group.rb +105 -0
- data/lib/tlogger/tlogger.rb +380 -0
- data/lib/tlogger/version.rb +1 -1
- data/samples/basic.rb +64 -35
- data/samples/group.rb +54 -0
- data/tlogger.gemspec +12 -27
- metadata +21 -74
- data/Gemfile.lock +0 -31
- data/LICENSE.txt +0 -21
- data/release.job +0 -53
- data/samples/basic2.rb +0 -25
data/lib/tlogger/version.rb
CHANGED
data/samples/basic.rb
CHANGED
@@ -1,44 +1,73 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
3
|
+
require 'tlogger'
|
4
|
+
|
5
|
+
log = Tlogger::Tlogger.new
|
6
|
+
|
7
|
+
log.debug "Without tagging"
|
8
|
+
log.info "Without tagging"
|
9
|
+
log.warn "Without tagging"
|
10
|
+
log.error "Without tagging"
|
11
|
+
|
12
|
+
# default tag for this loging session
|
13
|
+
log.tag = "global"
|
14
|
+
|
15
|
+
log.debug { "With default tagging" }
|
16
|
+
log.info { "With default tagging" }
|
17
|
+
log.warn { "With default tagging" }
|
18
|
+
log.error { "With default tagging" }
|
19
|
+
|
20
|
+
# include the file and location where the log message is printed out
|
21
|
+
log.include_caller = true
|
22
|
+
log.tdebug :mytag, "With per log message tagging"
|
23
|
+
|
24
|
+
log.with_tag :block_tag do |log|
|
25
|
+
log.debug "Inside block"
|
26
|
+
log.info "inside block"
|
27
|
+
log.warn "inside block"
|
28
|
+
log.error "inside block"
|
29
|
+
end
|
30
|
+
|
31
|
+
log.debug "Outside block. Shall take default tag '#{log.tag}'"
|
32
|
+
|
33
|
+
log.debug "About to show log message only show once. This can be useful if it is a warning which only print out per run."
|
34
|
+
(0..4).each do |i|
|
35
|
+
# Show message once only
|
36
|
+
# one time message tie to key
|
37
|
+
# Means if the message is under specific key and already prompted, it will skip
|
38
|
+
# Else it will be printed
|
39
|
+
log.odebug :debug_once, &-> { "this is one time message" }
|
40
|
+
log.oerror :error_once, "One time error"
|
41
|
+
log.oinfo :info_once, "One time info"
|
42
|
+
log.owarn :warn_once, "One time warning"
|
43
|
+
log.owarn :warn_once, "One time warning" # this line shall be skipped
|
44
|
+
log.oinfo :info_once, "One time info" # this line shall be skipped too
|
45
|
+
# from the output, even this is looped 5 times, only 4 messages shall be printed out
|
30
46
|
end
|
31
47
|
|
32
|
-
|
48
|
+
log.info "Shall turned off all except tag :whatever"
|
49
|
+
log.off_all_except(:whatever,:global)
|
50
|
+
log.tdebug :another_global, "I've been turned off" # this line shall not show in the log output
|
51
|
+
log.terror :whatever, "I will survive!" # this line will show up because it is being exampted
|
52
|
+
log.tinfo :global, "Got turned off" # this line will show up because it is being exampted
|
33
53
|
|
34
|
-
|
35
|
-
#
|
36
|
-
#Tlogger::TloggerConf.disable_tag([:cls])
|
54
|
+
log.remove_from_exception(:global)
|
55
|
+
log.twarn :global, "Since :global is removed from exception, will it print out?" # this line will not show up because it has removed from examption and shall be off
|
37
56
|
|
38
|
-
|
39
|
-
|
40
|
-
|
57
|
+
log.on_all_except(:global)
|
58
|
+
log.tdebug :another_global, "Now it is my turn to be here" # this line will show up because all is on
|
59
|
+
log.terror :whatever, "Yeah me too!" # this line will show up because all is on
|
60
|
+
log.debug "I'm inherited from key :global so I'm also not visible" # due to on_all_except(:global) this line shall not be printed
|
61
|
+
log.tinfo :global, "Gosh! I've been turned off by default" # due to on_all_except(:global) this line shall not be printed
|
62
|
+
log.twarn :local, "I'm free!" # this line will show up because all is on
|
41
63
|
|
42
|
-
|
64
|
+
x = 2
|
65
|
+
# Log only print if the first parameters is true.
|
66
|
+
log.ifdebug(x == 2, :ifdebug, "Debug : x == 2!")
|
67
|
+
log.iferror(x == 2, :iferror, "Err : x == 2!")
|
68
|
+
log.ifinfo(x == 2, :ifinfo, "Info: x == 2!")
|
69
|
+
log.ifwarn(x == 2, :ifwarn, "Warn: x == 2!")
|
43
70
|
|
71
|
+
# first param also can be a proc
|
72
|
+
log.ifdebug Proc.new { x == 2 }, :ifdebug2, "Debug 2 : x == 2!"
|
44
73
|
|
data/samples/group.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require "tlogger"
|
4
|
+
include Tlogger
|
5
|
+
|
6
|
+
mlog = LoggerGroup.new
|
7
|
+
# create logger goes to STDOUT
|
8
|
+
lout = mlog.create_logger(:stdout, STDOUT)
|
9
|
+
# create logger using default parameter, to STDOUT too
|
10
|
+
# lout = mlog.create_logger(:stdout2)
|
11
|
+
# create logger to a log file test.log
|
12
|
+
lfile = mlog.create_logger(:file,"test.log", 10, 1024000)
|
13
|
+
# create logger to memory buffer
|
14
|
+
buf = StringIO.new
|
15
|
+
lbuf = mlog.create_logger(:io,buf)
|
16
|
+
|
17
|
+
|
18
|
+
mlog.with_tag(:block) do |log|
|
19
|
+
# following 4 lines shall all be printed in all given 3 loggers
|
20
|
+
log.debug "inside block"
|
21
|
+
log.error "Wow error!"
|
22
|
+
log.info "Still inside block"
|
23
|
+
log.warn "Warning!"
|
24
|
+
|
25
|
+
# following 2 lines shall only got 1 line printed in all 3 loggers
|
26
|
+
log.odebug :once, "this should print out once!"
|
27
|
+
log.odebug :once, "this should print out once!"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# following two lines shall be printed on STDOUT only
|
32
|
+
lout.tdebug :test, "test output"
|
33
|
+
lout.debug "again"
|
34
|
+
|
35
|
+
ioLog = mlog.detach_logger(:io)
|
36
|
+
|
37
|
+
# this line shall not be printed to memory buffer but shall be in other 2
|
38
|
+
mlog.debug "Last line"
|
39
|
+
|
40
|
+
ioLog.info "This only inside memory buffer"
|
41
|
+
|
42
|
+
buf.rewind
|
43
|
+
dat = buf.read
|
44
|
+
puts "**** Content of memory buffer ****"
|
45
|
+
dat.each_line do |l|
|
46
|
+
puts l.strip
|
47
|
+
end
|
48
|
+
puts "**** End of content of memory buffer ****"
|
49
|
+
|
50
|
+
mlog.close
|
51
|
+
|
52
|
+
# since this log already detach, application should close it when finished using it
|
53
|
+
ioLog.close
|
54
|
+
|
data/tlogger.gemspec
CHANGED
@@ -1,31 +1,23 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "tlogger/version"
|
1
|
+
require_relative 'lib/tlogger/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = "tlogger"
|
8
5
|
spec.version = Tlogger::VERSION
|
9
|
-
spec.authors = ["Chris
|
6
|
+
spec.authors = ["Chris"]
|
10
7
|
spec.email = ["chrisliaw@antrapol.com"]
|
11
8
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage = ""
|
15
|
-
spec.
|
9
|
+
spec.summary = %q{Logger that added contextual information to the log messages}
|
10
|
+
spec.description = %q{Logger that provides some control over how the log messages are being displayed with conditionally enable and disable certain log messages from showing based on configurations}
|
11
|
+
spec.homepage = "https://github.com/chrisliaw/tlogger"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.licenses = ["MIT"]
|
16
15
|
|
17
|
-
#
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
#if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
17
|
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#else
|
26
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
-
# "public gem pushes."
|
28
|
-
#end
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
29
21
|
|
30
22
|
# Specify which files should be added to the gem when it is released.
|
31
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -35,11 +27,4 @@ Gem::Specification.new do |spec|
|
|
35
27
|
spec.bindir = "exe"
|
36
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
29
|
spec.require_paths = ["lib"]
|
38
|
-
|
39
|
-
spec.required_ruby_version = '>= 1.8.6'
|
40
|
-
|
41
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
42
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
43
|
-
spec.add_development_dependency "pry"
|
44
|
-
spec.add_development_dependency "pry-byebug"
|
45
30
|
end
|
metadata
CHANGED
@@ -1,72 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Chris
|
8
|
-
autorequire:
|
7
|
+
- Chris
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry-byebug
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description: ''
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Logger that provides some control over how the log messages are being
|
14
|
+
displayed with conditionally enable and disable certain log messages from showing
|
15
|
+
based on configurations
|
70
16
|
email:
|
71
17
|
- chrisliaw@antrapol.com
|
72
18
|
executables: []
|
@@ -74,24 +20,26 @@ extensions: []
|
|
74
20
|
extra_rdoc_files: []
|
75
21
|
files:
|
76
22
|
- ".gitignore"
|
23
|
+
- ".travis.yml"
|
24
|
+
- CODE_OF_CONDUCT.md
|
77
25
|
- Gemfile
|
78
|
-
- Gemfile.lock
|
79
|
-
- LICENSE.txt
|
80
26
|
- README.md
|
81
27
|
- Rakefile
|
82
28
|
- bin/console
|
83
29
|
- bin/setup
|
84
30
|
- lib/tlogger.rb
|
31
|
+
- lib/tlogger/logger_group.rb
|
32
|
+
- lib/tlogger/tlogger.rb
|
85
33
|
- lib/tlogger/version.rb
|
86
|
-
- release.job
|
87
34
|
- samples/basic.rb
|
88
|
-
- samples/
|
35
|
+
- samples/group.rb
|
89
36
|
- tlogger.gemspec
|
90
|
-
homepage:
|
37
|
+
homepage: https://github.com/chrisliaw/tlogger
|
91
38
|
licenses:
|
92
39
|
- MIT
|
93
|
-
metadata:
|
94
|
-
|
40
|
+
metadata:
|
41
|
+
homepage_uri: https://github.com/chrisliaw/tlogger
|
42
|
+
post_install_message:
|
95
43
|
rdoc_options: []
|
96
44
|
require_paths:
|
97
45
|
- lib
|
@@ -99,16 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
47
|
requirements:
|
100
48
|
- - ">="
|
101
49
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
50
|
+
version: 2.3.0
|
103
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
52
|
requirements:
|
105
53
|
- - ">="
|
106
54
|
- !ruby/object:Gem::Version
|
107
55
|
version: '0'
|
108
56
|
requirements: []
|
109
|
-
|
110
|
-
|
111
|
-
signing_key:
|
57
|
+
rubygems_version: 3.1.4
|
58
|
+
signing_key:
|
112
59
|
specification_version: 4
|
113
|
-
summary:
|
60
|
+
summary: Logger that added contextual information to the log messages
|
114
61
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
tlogger (0.5.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
byebug (11.0.1)
|
10
|
-
coderay (1.1.2)
|
11
|
-
method_source (0.9.2)
|
12
|
-
pry (0.12.2)
|
13
|
-
coderay (~> 1.1.0)
|
14
|
-
method_source (~> 0.9.0)
|
15
|
-
pry-byebug (3.7.0)
|
16
|
-
byebug (~> 11.0)
|
17
|
-
pry (~> 0.10)
|
18
|
-
rake (10.5.0)
|
19
|
-
|
20
|
-
PLATFORMS
|
21
|
-
ruby
|
22
|
-
|
23
|
-
DEPENDENCIES
|
24
|
-
bundler (~> 2.0)
|
25
|
-
pry
|
26
|
-
pry-byebug
|
27
|
-
rake (~> 10.0)
|
28
|
-
tlogger!
|
29
|
-
|
30
|
-
BUNDLED WITH
|
31
|
-
2.0.1
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2019 Chris Liaw
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/release.job
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
job :release do
|
4
|
-
|
5
|
-
include_job :prompt_version
|
6
|
-
#ver = prompt "Please provide version for this release:", required: true
|
7
|
-
#set :releasing_version, ver
|
8
|
-
|
9
|
-
include_job :build
|
10
|
-
include_job :check_in
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
job :prompt_version do
|
15
|
-
if get(:releasing_version) == nil
|
16
|
-
ver = prompt "Please provide version for this release:", required: true
|
17
|
-
set :releasing_version, ver
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
job :build do
|
22
|
-
|
23
|
-
dir '/Volumes/Stash/08.Dev/01.Workspaces/incu-2019/tlogger'
|
24
|
-
|
25
|
-
include_job :prompt_version
|
26
|
-
|
27
|
-
rubygem do
|
28
|
-
#publish build('alog.gemspec'), ignore_status: true #do |res|
|
29
|
-
build('tlogger.gemspec') do |res|
|
30
|
-
publish(res, ignore_status: true)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
job :check_in do
|
38
|
-
dir '/Volumes/Stash/08.Dev/01.Workspaces/incu-2019/tlogger'
|
39
|
-
git do
|
40
|
-
commit
|
41
|
-
tag
|
42
|
-
push 'origin', 'master'
|
43
|
-
push 'git','master'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
job :reinstall do
|
48
|
-
rubygem do
|
49
|
-
uninstall 'tlogger'
|
50
|
-
install 'tlogger'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|