logue 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/.glarkrc +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/logue/frame.rb +28 -0
- data/lib/logue/line.rb +22 -0
- data/lib/logue/location.rb +25 -0
- data/lib/logue/location_format.rb +47 -0
- data/lib/logue/logger.rb +26 -45
- data/lib/logue/version.rb +6 -0
- data/lib/logue.rb +0 -4
- data/logue.gemspec +38 -0
- metadata +81 -38
- data/lib/logue/format.rb +0 -38
- data/lib/logue/writer.rb +0 -24
- data/test/logue/colors_test.rb +0 -12
- data/test/logue/format_test.rb +0 -59
- data/test/logue/log_test.rb +0 -88
- data/test/logue/loggable_test.rb +0 -72
- data/test/logue/logger_test.rb +0 -30
- data/test/logue/pathutil_test.rb +0 -73
- data/test/logue/testlog/log_stack_test.rb +0 -97
- data/test/logue/testlog/log_test.rb +0 -167
- data/test/logue/testlog/loggable_test.rb +0 -30
- data/test/logue/writer_test.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c631370d89c9801cdd921d69062367afc6dcf4
|
4
|
+
data.tar.gz: e717280f09746f258be9bfce45429a0d16e085f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffcaadb309d8bc25b31e8e0afb20794843ee14d06647dbfee7c40ef8cfcef4857ff8f03efb93ac3d49e12ed58529e07b9e7601d7b74c87409fffdfd996dc6ffa
|
7
|
+
data.tar.gz: 53e1c1d6f8aaf4ab8868bc4d4e30f52f4b826582363bf4062af4069460931886f1916d681e366519508215d58e7fcaeeede92e8603004de18cbc94122a9ad931
|
data/.gitignore
ADDED
data/.glarkrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
skip-path: pkg
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
logue (1.0.9)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
paramesan (0.1.1)
|
10
|
+
power_assert (1.1.1)
|
11
|
+
rainbow (3.0.0)
|
12
|
+
rake (10.5.0)
|
13
|
+
test-unit (3.2.7)
|
14
|
+
power_assert
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.16)
|
21
|
+
logue!
|
22
|
+
paramesan (~> 0.1.1)
|
23
|
+
rainbow (~> 3.0.0)
|
24
|
+
rake (~> 10.0)
|
25
|
+
test-unit (~> 3.1)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jeff Pace
|
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/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "arbolobra"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/logue/frame.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module Logue
|
7
|
+
class Frame
|
8
|
+
FRAME_RE = Regexp.new '(.*):(\d+)(?::in \`(.*)\')?'
|
9
|
+
|
10
|
+
attr_reader :path
|
11
|
+
attr_reader :line
|
12
|
+
attr_reader :function
|
13
|
+
|
14
|
+
def initialize args
|
15
|
+
if entry = args[:entry]
|
16
|
+
md = FRAME_RE.match entry
|
17
|
+
# Ruby 1.9 expands the file name, but 1.8 doesn't:
|
18
|
+
@path = Pathname.new(md[1]).expand_path.to_s
|
19
|
+
@line = md[2].to_i
|
20
|
+
@function = md[3] || ""
|
21
|
+
else
|
22
|
+
@path = args[:path]
|
23
|
+
@line = args[:line]
|
24
|
+
@function = args[:function]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/logue/line.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'logue/location_format'
|
5
|
+
|
6
|
+
module Logue
|
7
|
+
end
|
8
|
+
|
9
|
+
class Logue::Line
|
10
|
+
attr_reader :location
|
11
|
+
attr_reader :msg
|
12
|
+
|
13
|
+
def initialize location, msg
|
14
|
+
@location = location
|
15
|
+
@msg = msg
|
16
|
+
end
|
17
|
+
|
18
|
+
def format locformat
|
19
|
+
logmsg = @location.format locformat
|
20
|
+
logmsg + " " + @msg
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'logue/location_format'
|
5
|
+
|
6
|
+
module Logue
|
7
|
+
end
|
8
|
+
|
9
|
+
class Logue::Location
|
10
|
+
attr_reader :path
|
11
|
+
attr_reader :lineno
|
12
|
+
attr_reader :cls
|
13
|
+
attr_reader :function
|
14
|
+
|
15
|
+
def initialize path, lineno, cls, function
|
16
|
+
@path = path
|
17
|
+
@lineno = lineno
|
18
|
+
@cls = cls
|
19
|
+
@function = function
|
20
|
+
end
|
21
|
+
|
22
|
+
def format locformat
|
23
|
+
locformat.format @path, @lineno, @cls, @function
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
require 'logue/pathutil'
|
5
|
+
|
6
|
+
class Logue::LocationFormatWidths
|
7
|
+
DEFAULT_FILENAME = -25
|
8
|
+
DEFAULT_LINE = 4
|
9
|
+
DEFAULT_FUNCTION = -20
|
10
|
+
end
|
11
|
+
|
12
|
+
class Logue::LocationFormat
|
13
|
+
attr_accessor :file
|
14
|
+
attr_accessor :line
|
15
|
+
attr_accessor :function
|
16
|
+
attr_accessor :trim
|
17
|
+
|
18
|
+
def initialize args = Hash.new
|
19
|
+
@file = args.fetch :file, Logue::LocationFormatWidths::DEFAULT_FILENAME
|
20
|
+
@line = args.fetch :line, Logue::LocationFormatWidths::DEFAULT_LINE
|
21
|
+
@function = args.fetch :function, Logue::LocationFormatWidths::DEFAULT_FUNCTION
|
22
|
+
@trim = args.fetch :trim, true
|
23
|
+
end
|
24
|
+
|
25
|
+
def copy args
|
26
|
+
values = { file: @file, line: @line, function: @function, trim: @trim }
|
27
|
+
self.class.new values.merge(args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def format path, line, cls, func
|
31
|
+
if cls
|
32
|
+
func = cls.to_s + "#" + func
|
33
|
+
end
|
34
|
+
|
35
|
+
if trim
|
36
|
+
path = Logue::PathUtil.trim_right path, @file
|
37
|
+
func = Logue::PathUtil.trim_left func, @function
|
38
|
+
end
|
39
|
+
|
40
|
+
format = "[%#{file}s:%#{@line}d] {%#{function}s}"
|
41
|
+
sprintf format, path, line, func
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_string
|
45
|
+
"[%#{file}s:%#{line}d] {%#{function}s}"
|
46
|
+
end
|
47
|
+
end
|
data/lib/logue/logger.rb
CHANGED
@@ -10,10 +10,12 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
require 'rainbow/x11_color_names'
|
13
|
+
require 'rainbow/color'
|
13
14
|
require 'pathname'
|
14
15
|
require 'logue/severity'
|
15
|
-
require 'logue/
|
16
|
+
require 'logue/location_format'
|
16
17
|
require 'logue/pathutil'
|
18
|
+
require 'logue/frame'
|
17
19
|
|
18
20
|
#
|
19
21
|
# == Logger
|
@@ -30,9 +32,6 @@ module Logue
|
|
30
32
|
end
|
31
33
|
|
32
34
|
class Logue::Logger
|
33
|
-
$LOGGING_LEVEL = nil
|
34
|
-
|
35
|
-
attr_accessor :quiet
|
36
35
|
attr_accessor :output
|
37
36
|
attr_accessor :colorize_line
|
38
37
|
attr_accessor :level
|
@@ -40,14 +39,12 @@ class Logue::Logger
|
|
40
39
|
attr_accessor :ignored_methods
|
41
40
|
attr_accessor :ignored_classes
|
42
41
|
|
43
|
-
|
42
|
+
attr_accessor :format
|
44
43
|
|
45
44
|
include Logue::Log::Severity
|
46
45
|
|
47
|
-
FRAME_RE = Regexp.new('(.*):(\d+)(?::in \`(.*)\')?')
|
48
|
-
|
49
46
|
def initialize
|
50
|
-
|
47
|
+
reset
|
51
48
|
end
|
52
49
|
|
53
50
|
def verbose= v
|
@@ -61,46 +58,42 @@ class Logue::Logger
|
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
64
|
-
def
|
65
|
-
|
61
|
+
def reset
|
62
|
+
@level = FATAL
|
66
63
|
@ignored_files = Hash.new
|
67
64
|
@ignored_methods = Hash.new
|
68
65
|
@ignored_classes = Hash.new
|
69
66
|
@output = $stdout
|
70
67
|
@colors = Array.new
|
71
68
|
@colorize_line = false
|
72
|
-
@
|
73
|
-
@trim = true
|
74
|
-
|
75
|
-
@format = Logue::Format.new
|
76
|
-
|
77
|
-
set_default_widths
|
69
|
+
@format = Logue::LocationFormat.new
|
78
70
|
end
|
79
71
|
|
80
72
|
def trim= what
|
81
73
|
end
|
82
74
|
|
75
|
+
def verbose
|
76
|
+
level <= DEBUG
|
77
|
+
end
|
78
|
+
|
83
79
|
def set_default_widths
|
84
|
-
|
80
|
+
@format = Logue::LocationFormat.new
|
85
81
|
end
|
86
82
|
|
87
83
|
def verbose
|
88
84
|
level <= DEBUG
|
89
85
|
end
|
90
86
|
|
91
|
-
# Assigns output to a file with the given name. Returns the file; client
|
92
|
-
#
|
87
|
+
# Assigns output to a file with the given name. Returns the file; the client is responsible for
|
88
|
+
# closing it.
|
93
89
|
def outfile= f
|
94
90
|
@output = f.kind_of?(IO) ? f : File.new(f, "w")
|
95
91
|
end
|
96
92
|
|
97
|
-
# Creates a printf format for the given widths, for aligning output. To lead
|
98
|
-
#
|
99
|
-
|
100
|
-
|
101
|
-
@file_width = file_width
|
102
|
-
@line_width = line_width
|
103
|
-
@function_width = func_width
|
93
|
+
# Creates a printf format for the given widths, for aligning output. To lead lines with zeros
|
94
|
+
# (e.g., "00317") the line_width argument must be a string, not an integer.
|
95
|
+
def set_widths file, line, function
|
96
|
+
@format = Logue::LocationFormat.new file: file, line: line, function: function
|
104
97
|
end
|
105
98
|
|
106
99
|
def ignore_file fname
|
@@ -178,29 +171,16 @@ class Logue::Logger
|
|
178
171
|
end
|
179
172
|
|
180
173
|
def print_stack_frame frame, cname, msg, lvl, &blk
|
181
|
-
|
182
|
-
|
183
|
-
# file.sub!(/.*\//, "")
|
184
|
-
|
185
|
-
# Ruby 1.9 expands the file name, but 1.8 doesn't:
|
186
|
-
pn = Pathname.new(file).expand_path
|
174
|
+
frm = Logue::Frame.new entry: frame
|
175
|
+
func = cname ? cname + "#" + frm.function : frm.function
|
187
176
|
|
188
|
-
|
189
|
-
|
190
|
-
if cname
|
191
|
-
func = cname + "#" + func
|
192
|
-
end
|
193
|
-
|
194
|
-
if ignored_files[file] || (cname && ignored_classes[cname]) || ignored_methods[func]
|
195
|
-
# skip this one.
|
196
|
-
else
|
197
|
-
print_formatted(file, line, func, msg, lvl, &blk)
|
177
|
+
unless ignored_files[frm.path] || (cname && ignored_classes[cname]) || ignored_methods[func]
|
178
|
+
print_formatted(frm.path, frm.line, func, msg, lvl, &blk)
|
198
179
|
end
|
199
180
|
end
|
200
181
|
|
201
182
|
def print_formatted file, line, func, msg, lvl, &blk
|
202
|
-
|
203
|
-
location = fmt.format file, line, nil, func
|
183
|
+
location = @format.format file, line, nil, func
|
204
184
|
print location, msg, lvl, &blk
|
205
185
|
end
|
206
186
|
|
@@ -245,7 +225,8 @@ class Logue::Logger
|
|
245
225
|
end
|
246
226
|
|
247
227
|
def respond_to? meth
|
248
|
-
validcolors = Rainbow::X11ColorNames::NAMES
|
228
|
+
# validcolors = Rainbow::X11ColorNames::NAMES
|
229
|
+
validcolors = Rainbow::Color::Named::NAMES
|
249
230
|
validcolors.include?(meth) || super
|
250
231
|
end
|
251
232
|
|
data/lib/logue.rb
CHANGED
data/logue.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "logue/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "logue"
|
8
|
+
spec.version = Logue::VERSION
|
9
|
+
spec.authors = ["Jeff Pace"]
|
10
|
+
spec.email = ["jeugenepace@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A minimalist logging module.}
|
13
|
+
spec.description = %q{A module that adds logging/trace functionality.}
|
14
|
+
spec.homepage = "https://www.github.com/jpace/logue"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
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"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
34
|
+
spec.add_development_dependency "rainbow", "~> 3.0.0"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "test-unit", "~> 3.1"
|
37
|
+
spec.add_development_dependency "paramesan", "~> 0.1.1"
|
38
|
+
end
|
metadata
CHANGED
@@ -1,66 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Pace
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rainbow
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
|
33
|
+
version: 3.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
21
46
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
type: :
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
24
49
|
prerelease: false
|
25
50
|
version_requirements: !ruby/object:Gem::Requirement
|
26
51
|
requirements:
|
27
52
|
- - "~>"
|
28
53
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
31
67
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: paramesan
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.1
|
33
83
|
description: A module that adds logging/trace functionality.
|
34
|
-
email:
|
84
|
+
email:
|
85
|
+
- jeugenepace@gmail.com
|
35
86
|
executables: []
|
36
87
|
extensions: []
|
37
|
-
extra_rdoc_files:
|
38
|
-
- README.md
|
88
|
+
extra_rdoc_files: []
|
39
89
|
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".glarkrc"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
40
95
|
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
41
99
|
- lib/logue.rb
|
42
100
|
- lib/logue/colors.rb
|
43
|
-
- lib/logue/
|
101
|
+
- lib/logue/frame.rb
|
102
|
+
- lib/logue/line.rb
|
103
|
+
- lib/logue/location.rb
|
104
|
+
- lib/logue/location_format.rb
|
44
105
|
- lib/logue/log.rb
|
45
106
|
- lib/logue/loggable.rb
|
46
107
|
- lib/logue/logger.rb
|
47
108
|
- lib/logue/pathutil.rb
|
48
109
|
- lib/logue/severity.rb
|
49
|
-
- lib/logue/
|
50
|
-
-
|
51
|
-
|
52
|
-
- test/logue/log_test.rb
|
53
|
-
- test/logue/loggable_test.rb
|
54
|
-
- test/logue/logger_test.rb
|
55
|
-
- test/logue/pathutil_test.rb
|
56
|
-
- test/logue/testlog/log_stack_test.rb
|
57
|
-
- test/logue/testlog/log_test.rb
|
58
|
-
- test/logue/testlog/loggable_test.rb
|
59
|
-
- test/logue/writer_test.rb
|
60
|
-
homepage: http://jpace.github.com/logue
|
110
|
+
- lib/logue/version.rb
|
111
|
+
- logue.gemspec
|
112
|
+
homepage: https://www.github.com/jpace/logue
|
61
113
|
licenses:
|
62
114
|
- MIT
|
63
|
-
metadata:
|
115
|
+
metadata:
|
116
|
+
allowed_push_host: https://rubygems.org
|
64
117
|
post_install_message:
|
65
118
|
rdoc_options: []
|
66
119
|
require_paths:
|
@@ -81,14 +134,4 @@ rubygems_version: 2.6.3
|
|
81
134
|
signing_key:
|
82
135
|
specification_version: 4
|
83
136
|
summary: A minimalist logging module.
|
84
|
-
test_files:
|
85
|
-
- test/logue/colors_test.rb
|
86
|
-
- test/logue/format_test.rb
|
87
|
-
- test/logue/log_test.rb
|
88
|
-
- test/logue/loggable_test.rb
|
89
|
-
- test/logue/logger_test.rb
|
90
|
-
- test/logue/pathutil_test.rb
|
91
|
-
- test/logue/testlog/log_stack_test.rb
|
92
|
-
- test/logue/testlog/log_test.rb
|
93
|
-
- test/logue/testlog/loggable_test.rb
|
94
|
-
- test/logue/writer_test.rb
|
137
|
+
test_files: []
|
data/lib/logue/format.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'logue/pathutil'
|
5
|
-
|
6
|
-
class Logue::FormatWidths
|
7
|
-
DEFAULT_FILENAME = -25
|
8
|
-
DEFAULT_LINENUM = 4
|
9
|
-
DEFAULT_FUNCTION = -20
|
10
|
-
end
|
11
|
-
|
12
|
-
class Logue::Format
|
13
|
-
def initialize args = Hash.new
|
14
|
-
@file_width = args.fetch :file_width, Logue::FormatWidths::DEFAULT_FILENAME
|
15
|
-
@line_width = args.fetch :line_width, Logue::FormatWidths::DEFAULT_LINENUM
|
16
|
-
@method_width = args.fetch :method_width, Logue::FormatWidths::DEFAULT_FUNCTION
|
17
|
-
@trim = args.fetch :trim, true
|
18
|
-
end
|
19
|
-
|
20
|
-
def copy args
|
21
|
-
values = { file_width: @file_width, line_width: @line_width, method_width: @method_width, trim: @trim }
|
22
|
-
self.class.new values.merge(args)
|
23
|
-
end
|
24
|
-
|
25
|
-
def format path, lineno, cls, func
|
26
|
-
if cls
|
27
|
-
func = cls.to_s + "#" + func
|
28
|
-
end
|
29
|
-
|
30
|
-
if @trim
|
31
|
-
path = Logue::PathUtil.trim_right path, @file_width
|
32
|
-
func = Logue::PathUtil.trim_left func, @method_width
|
33
|
-
end
|
34
|
-
|
35
|
-
format = "[%#{@file_width}s:%#{@line_width}d] {%#{@method_width}s}"
|
36
|
-
sprintf format, path, lineno, func
|
37
|
-
end
|
38
|
-
end
|
data/lib/logue/writer.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'logue/format'
|
5
|
-
|
6
|
-
module Logue
|
7
|
-
end
|
8
|
-
|
9
|
-
class Logue::Writer
|
10
|
-
attr_accessor :out
|
11
|
-
|
12
|
-
def initialize out = $stdout
|
13
|
-
@out = out
|
14
|
-
end
|
15
|
-
|
16
|
-
def write fmt, stack, nframes, cls = nil
|
17
|
-
stack[0 ... nframes].each do |frame|
|
18
|
-
path = frame.absolute_path
|
19
|
-
lineno = frame.lineno
|
20
|
-
func = frame.label
|
21
|
-
@out.puts fmt.format path, lineno, cls, func
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|