logger_ext 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9fdadfae22e13d3fa0406fc25cad5554c3e8416
4
+ data.tar.gz: 3455b8b78426133eb3c148ab9acd8bc2df6fd54f
5
+ SHA512:
6
+ metadata.gz: cec99f31d54d4598b82225ad1b1ced61cb077323a09243aa7e37e27e05cadfd8c26fc21fb70e7a97fb343830ac0a7531f50c64a551bd0a92426943410fdf3038
7
+ data.tar.gz: 3c5af72311a22dcd0632fbbe5eff0aa765211140c5d7426617419b742421568e6f61220d3bba3baa6d12f330d3909888dc798bba295d0a371fd64573188fa63c
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # extended_logger
2
+
3
+ ## Contributing
4
+
5
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mediapeers/extended_logger.
6
+
7
+
8
+ ## License
9
+
10
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
11
+
data/lib/logger_ext.rb ADDED
@@ -0,0 +1,49 @@
1
+ require "logger_ext/version"
2
+ require "logger"
3
+
4
+ class Logger
5
+ def add_structured(severity, message, *args, &block)
6
+ return unless level <= severity
7
+
8
+ if block
9
+ # Note: this will raise an error if args is not empty
10
+ add severity, nil, message, *args, &block
11
+ else
12
+ message += ": #{args.shift.inspect}" unless args.empty?
13
+ args.each_with_index do |arg, idx|
14
+ message += ", #{arg.inspect}"
15
+ end
16
+ add severity, message, nil
17
+ end
18
+ end
19
+
20
+ # Log a +DEBUG+ message.
21
+ def debug(message, *args, &block)
22
+ add_structured(DEBUG, message, *args, &block)
23
+ end
24
+
25
+ # Log an +INFO+ message.
26
+ def info(message, *args, &block)
27
+ add_structured(INFO, message, *args, &block)
28
+ end
29
+
30
+ # Log a +WARN+ message.
31
+ def warn(message, *args, &block)
32
+ add_structured(WARN, message, *args, &block)
33
+ end
34
+
35
+ # Log an +ERROR+ message.
36
+ def error(message, *args, &block)
37
+ add_structured(ERROR, message, *args, &block)
38
+ end
39
+
40
+ # Log a +FATAL+ message.
41
+ def fatal(message, *args, &block)
42
+ add_structured(FATAL, message, *args, &block)
43
+ end
44
+
45
+ # Log an +UNKNOWN+ message.
46
+ def unknown(message, *args, &block)
47
+ add_structured(UNKNOWN, message, *args, &block)
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module LoggerExt
2
+ VERSION = "0.1.4"
3
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe LoggerExt do
4
+ let(:null_file) { File.open "/dev/null", "a" }
5
+ let(:logger) { Logger.new null_file }
6
+
7
+ it "can log with the old interface" do
8
+ logger.debug "foo"
9
+ logger.info "foo"
10
+ logger.warn "foo"
11
+ logger.error "foo"
12
+ logger.fatal "foo"
13
+ logger.unknown "foo"
14
+ end
15
+
16
+ it "can log with additional arguments" do
17
+ logger.warn "foo", "bar"
18
+ logger.warn "foo", "bar", "baz"
19
+ logger.warn "foo", "bar", hi: "ha"
20
+ logger.warn "foo", hi: "ha"
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ require "rspec"
2
+ require "logger_ext"
3
+
4
+ RSpec.configure do |config|
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run focus: (ENV["CI"] != "true")
7
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
8
+ config.order = "random"
9
+
10
+ config.before(:all) {}
11
+ config.after {}
12
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logger_ext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - radiospiel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.5.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.5.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.5.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.5.0
41
+ description: extend Ruby's default logger interface to support multiple arguments
42
+ email:
43
+ - radiospiel@open-lab.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - lib/logger_ext.rb
50
+ - lib/logger_ext/version.rb
51
+ - spec/extended_logger/extended_logger_spec.rb
52
+ - spec/spec_helper.rb
53
+ homepage: https://github.com/radiospiel/postqueue
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.5.1
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: extend Ruby's default logger interface to support multiple arguments
77
+ test_files: []