jellog 1.0.14 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/History.txt +12 -0
- data/README.md +20 -1
- data/bin/jellog +1 -1
- data/lib/jellog/proxy.rb +90 -0
- data/lib/jellog/version.rb +8 -8
- data/spec/jellog_logger_spec.rb +2 -0
- data/test/conf.d/{jellogga.rb → jellog.rb} +0 -0
- data/test/jellogtest.log +6 -6
- data/test/jellogtest1.log +6 -6
- data/test/jellogtest2.log +6 -6
- data/test/proxy_test.rb +60 -0
- metadata +79 -85
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGM0ZjQyNmVkMzRiMDMyZjM4MzI2YjFjN2UxODQ0NTk3ODc3OGUwZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmE5YjYzYzZlODBjZTFiN2FlMzYxYmUyMWE1MTYzNTQ1NWEyZWE2MQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDE2MGQ5NzllZjg1MzEzNTBiOWNlODJhODk0NjMwZDc3OGZkYzQ5MGUxMWJl
|
10
|
+
ZmYxZWIwZjgwOTg4M2I3NzE2OGNjMzZiYTE0YTFkMjNmZDVmMDhlYmNlMTY5
|
11
|
+
MWJkZTdmMmFkZTNmMmRmZTZhNTA2ZTM1NDcwYmQ4ZTc2MGUzMTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWJhOWI5ZTg4ZjhjOGQ3MDVlOTQ5OWFmMmI2OGJjNTFlNWQ5N2NiNzBiODRm
|
14
|
+
MGMyY2UzMDBhN2EwZWM5MTcwN2E5MTA5NzY3MDBjYzg2NjIwZDMyN2JlMTc5
|
15
|
+
YTRhYjQ1ZGNiNjNhZGRkY2M5YTA2MTZkYTI3ZDE3YjBhZDhiYWQ=
|
data/History.txt
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
== History
|
2
2
|
|
3
|
+
[jellog-1.0.17 02-Aug-2013]
|
4
|
+
|
5
|
+
Ensuring 1.9 compliance (just changed the shebang on the pointless bin file)
|
6
|
+
|
7
|
+
[jellog-1.0.16 02-Aug-2013]
|
8
|
+
|
9
|
+
Add :suppress option to block messages other than :warn, :error, :fatal and :exception
|
10
|
+
|
11
|
+
[jellog-1.0.15 19-Jul-2013]
|
12
|
+
|
13
|
+
Add a proxy logger to enable logging to either a full logger or to a display
|
14
|
+
|
3
15
|
[jellog-1.0.14 17-Nov-2012]
|
4
16
|
|
5
17
|
Revert to /var/log/jerbil
|
data/README.md
CHANGED
@@ -12,7 +12,8 @@ adds a few features that may be useful:
|
|
12
12
|
* provides a 'puts' method to enable apps to output to either console or log (e.g foreground
|
13
13
|
vs background);
|
14
14
|
* returns logged messages, e.g. to cascade into exceptions
|
15
|
-
* simple log level control
|
15
|
+
* simple log level control;
|
16
|
+
* proxy class that responds to same methods and outputs to stderr
|
16
17
|
|
17
18
|
|
18
19
|
**GitHub:** [https://github.com/osburn-sharp/jellog](https://github.com/osburn-sharp/jellog)
|
@@ -94,6 +95,24 @@ to the logger only. Check out the Jeckyl class method #intersection to get these
|
|
94
95
|
nonlog_opts = full_opts.complement(log_opts)
|
95
96
|
|
96
97
|
More details of Jeckyl can be found on [GitHub](https://github.com/osburn-sharp/jeckyl).
|
98
|
+
|
99
|
+
### Using the Proxy Logger
|
100
|
+
|
101
|
+
There may be times when you want to write code that can log to a full logger or just to the
|
102
|
+
display, depending on who calls it. Logging everything with puts may work but is very limited.
|
103
|
+
The proxy logger allows you to substitute a logger that responds to all the same methods
|
104
|
+
but outputs messages to the display - with colours but without timestamps.
|
105
|
+
|
106
|
+
For example, a module may be used by a service, in which case it would log messages to the
|
107
|
+
service's log using the service's logger. Or it may be used by a CLI, in which case you want the
|
108
|
+
same messages to go straight to the display.
|
109
|
+
|
110
|
+
proxy = Jellog::ProxyLogger.new(appname, options)
|
111
|
+
proxy.system "A system message"
|
112
|
+
|
113
|
+
Proxy responds to all the same methods. It does not log anything to syslog. By adding a
|
114
|
+
:suppress flag to the options, you can stop Proxy from producing anything other than
|
115
|
+
error messages.
|
97
116
|
|
98
117
|
## Code Walkthrough
|
99
118
|
|
data/bin/jellog
CHANGED
data/lib/jellog/proxy.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# = Jellog Stdout Logger
|
4
|
+
#
|
5
|
+
# == Looks like Jellog but outputs to stdout
|
6
|
+
#
|
7
|
+
# Author:: Robert Sharp
|
8
|
+
# Copyright:: Copyright (c) 2013 Robert Sharp
|
9
|
+
# License:: Open Software Licence v3.0
|
10
|
+
#
|
11
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
12
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
13
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
14
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
15
|
+
#
|
16
|
+
#
|
17
|
+
#
|
18
|
+
require 'jellog'
|
19
|
+
|
20
|
+
module Jellog
|
21
|
+
|
22
|
+
# A proxy for a conventional logger that outputs
|
23
|
+
# everything to stdout/stderr
|
24
|
+
#
|
25
|
+
class ProxyLogger < Jellog::Logger
|
26
|
+
|
27
|
+
# create a proxy logger
|
28
|
+
#
|
29
|
+
# can be used instead of {Jellog::Logger} to output logs to the
|
30
|
+
# display
|
31
|
+
#
|
32
|
+
# @params [String] appname to display in the log
|
33
|
+
# @params [Hash] log_opts hash of options
|
34
|
+
# @option [Symbol] :log_level to log to (:system, :verbose, :debug)
|
35
|
+
# @option [Boolean] :log_coloured
|
36
|
+
# @option [Boolean] :suppress messages unless warn, error or fatal
|
37
|
+
# @return [Jellog::ProxyLogger] self
|
38
|
+
def initialize(appname, log_opts={})
|
39
|
+
|
40
|
+
@appname = appname
|
41
|
+
#@log_opts = LogOpts.merge(log_opts)
|
42
|
+
|
43
|
+
@log_level = log_opts.delete(:log_level) || :system
|
44
|
+
@mark = log_opts[:log_mark] || ' *** MARK ***'
|
45
|
+
|
46
|
+
@logger = Jellog::Plogger.new(appname, log_opts[:log_coloured], log_opts[:suppress])
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# internal logger used by the proxy to send everything to stderr
|
53
|
+
class Plogger < Jellog::Slogger
|
54
|
+
|
55
|
+
# create a proxy output logger using stderr
|
56
|
+
#
|
57
|
+
# @params [String] appname to display in the log
|
58
|
+
# @params [Boolean] coloured or not
|
59
|
+
# @return [Jellog::Plogger] self
|
60
|
+
def initialize(appname, coloured, suppress)
|
61
|
+
# don't need a time stamp, so use the format string to prefix the appname
|
62
|
+
@format_str = appname
|
63
|
+
@coloured = coloured
|
64
|
+
@suppress = suppress
|
65
|
+
@colours = Levels
|
66
|
+
@logger = $stderr
|
67
|
+
end
|
68
|
+
|
69
|
+
# when suppress is enabled, ignore messages that are suppressed
|
70
|
+
def method_missing(meth, msg)
|
71
|
+
|
72
|
+
return if @suppress && suppressed_msgs.include?(meth)
|
73
|
+
|
74
|
+
super(meth, msg)
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# defines suppressed messages
|
79
|
+
def suppressed_msgs
|
80
|
+
[:system, :info, :verbose, :debug]
|
81
|
+
end
|
82
|
+
|
83
|
+
# ensure a user does not accidentally close stderr
|
84
|
+
def close
|
85
|
+
# do nothing
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/lib/jellog/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Created by Jevoom
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
3
|
+
# 02-Aug-2013
|
4
|
+
# Ensuring 1.9 compliance (just changed the shebang on the pointless bin file)
|
5
5
|
|
6
6
|
module Jellog
|
7
|
-
# version set to 1.0.
|
8
|
-
Version = '1.0.
|
9
|
-
# date set to
|
10
|
-
Version_Date = '
|
11
|
-
#ident string set to: jellog-1.0.
|
12
|
-
Ident = 'jellog-1.0.
|
7
|
+
# version set to 1.0.17
|
8
|
+
Version = '1.0.17'
|
9
|
+
# date set to 02-Aug-2013
|
10
|
+
Version_Date = '02-Aug-2013'
|
11
|
+
#ident string set to: jellog-1.0.17 02-Aug-2013
|
12
|
+
Ident = 'jellog-1.0.17 02-Aug-2013'
|
13
13
|
end
|
data/spec/jellog_logger_spec.rb
CHANGED
File without changes
|
data/test/jellogtest.log
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
[
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[
|
5
|
-
[
|
6
|
-
[
|
1
|
+
[2013-08-23 08:48:26] INFO - Hello
|
2
|
+
[2013-08-23 08:48:26] DEBUG - This should be green
|
3
|
+
[2013-08-23 08:48:26] WARN - This should be yellow
|
4
|
+
[2013-08-23 08:48:26] ERROR - This should be red
|
5
|
+
[2013-08-23 08:48:26] FATAL - This should be red and bold
|
6
|
+
[2013-08-23 08:48:26] SYSTEM - This should be blue
|
data/test/jellogtest1.log
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
[
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[
|
5
|
-
[
|
6
|
-
[
|
1
|
+
[2013-08-23 08:48:26] INFO - Hello
|
2
|
+
[2013-08-23 08:48:26] DEBUG - This should be white
|
3
|
+
[2013-08-23 08:48:26] WARN - This should be white
|
4
|
+
[2013-08-23 08:48:26] ERROR - This should be white
|
5
|
+
[2013-08-23 08:48:26] FATAL - This should be white
|
6
|
+
[2013-08-23 08:48:26] SYSTEM - This should be white
|
data/test/jellogtest2.log
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
[
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[
|
5
|
-
[
|
6
|
-
[
|
1
|
+
[2013-08-23 08:48:26] INFO - Hello
|
2
|
+
[2013-08-23 08:48:26] DEBUG - This should be red
|
3
|
+
[2013-08-23 08:48:26] WARN - This should be yellow
|
4
|
+
[2013-08-23 08:48:26] ERROR - This should be red
|
5
|
+
[2013-08-23 08:48:26] FATAL - This should be red and bold
|
6
|
+
[2013-08-23 08:48:26] SYSTEM - This should be green
|
data/test/proxy_test.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# = Test Stdout
|
4
|
+
#
|
5
|
+
# == SubTitle
|
6
|
+
#
|
7
|
+
# Author:: Robert Sharp
|
8
|
+
# Copyright:: Copyright (c) 2013 Robert Sharp
|
9
|
+
# License:: Open Software Licence v3.0
|
10
|
+
#
|
11
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
12
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
13
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
14
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
15
|
+
#
|
16
|
+
#
|
17
|
+
#
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
|
23
|
+
require 'jellog/proxy'
|
24
|
+
|
25
|
+
logger = Jellog::ProxyLogger.new('tester', :log_coloured=>true, :log_level=>:debug)
|
26
|
+
|
27
|
+
logger.system "System Message"
|
28
|
+
logger.info "Information Message"
|
29
|
+
logger.verbose "Verbose Message"
|
30
|
+
logger.debug "Debug Message"
|
31
|
+
logger.warn "Warning Message"
|
32
|
+
logger.error "Error Message"
|
33
|
+
logger.fatal "Fatal Message"
|
34
|
+
|
35
|
+
begin
|
36
|
+
raise ArgumentError, "Wrong argument"
|
37
|
+
rescue Exception => e
|
38
|
+
logger.exception(e)
|
39
|
+
end
|
40
|
+
|
41
|
+
logger.puts "A plain old bit of text to finish"
|
42
|
+
logger.mark
|
43
|
+
|
44
|
+
logger = Jellog::ProxyLogger.new('tester', :log_coloured=>true, :log_level=>:debug, :suppress=>true)
|
45
|
+
|
46
|
+
logger.system "System Message"
|
47
|
+
logger.info "Information Message"
|
48
|
+
logger.verbose "Verbose Message"
|
49
|
+
logger.debug "Debug Message"
|
50
|
+
logger.warn "Warning Message"
|
51
|
+
logger.error "Error Message"
|
52
|
+
logger.fatal "Fatal Message"
|
53
|
+
|
54
|
+
begin
|
55
|
+
raise ArgumentError, "Wrong argument"
|
56
|
+
rescue Exception => e
|
57
|
+
logger.exception(e)
|
58
|
+
end
|
59
|
+
|
60
|
+
logger.puts "A plain old bit of text to finish"
|
metadata
CHANGED
@@ -1,93 +1,95 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jellog
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 14
|
10
|
-
version: 1.0.14
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.17
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Dr Robert
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: !binary |-
|
15
|
+
dGVybS1hbnNpY29sb3I=
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
21
|
type: :runtime
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
name: term-ansicolor
|
32
|
-
version_requirements: *id001
|
33
22
|
prerelease: false
|
34
|
-
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: !binary |-
|
30
|
+
dGhvcg==
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
35
36
|
type: :runtime
|
36
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
name: thor
|
46
|
-
version_requirements: *id002
|
47
37
|
prerelease: false
|
48
|
-
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: !binary |-
|
45
|
+
amVja3ls
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
49
51
|
type: :runtime
|
50
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
name: jeckyl
|
60
|
-
version_requirements: *id003
|
61
52
|
prerelease: false
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
description: ! 'A wrapper class around the standard Ruby logger that adds a simply
|
59
|
+
logging level control
|
60
|
+
|
61
|
+
and the ability to log certain messages to syslog. It also adds a puts method so
|
62
|
+
that the
|
63
|
+
|
64
|
+
logger can be used instead of stdout etc. Output can be coloured depending on the
|
65
|
+
logging
|
66
|
+
|
66
67
|
level.
|
67
68
|
|
69
|
+
'
|
68
70
|
email: robert@osburn-sharp.ath.cx
|
69
|
-
executables:
|
71
|
+
executables:
|
70
72
|
- jellog
|
71
73
|
extensions: []
|
72
|
-
|
73
|
-
extra_rdoc_files:
|
74
|
+
extra_rdoc_files:
|
74
75
|
- History.txt
|
75
76
|
- Bugs.rdoc
|
76
77
|
- Intro.txt
|
77
78
|
- LICENCE.rdoc
|
78
79
|
- Gemfile
|
79
80
|
- README.md
|
80
|
-
files:
|
81
|
+
files:
|
81
82
|
- History.txt
|
82
83
|
- Bugs.rdoc
|
83
84
|
- Intro.txt
|
84
85
|
- LICENCE.rdoc
|
85
86
|
- Gemfile
|
86
87
|
- README.md
|
87
|
-
- lib/jellog/logger.rb
|
88
88
|
- lib/jellog/version.rb
|
89
89
|
- lib/jellog/config.rb
|
90
90
|
- lib/jellog/config.md
|
91
|
+
- lib/jellog/logger.rb
|
92
|
+
- lib/jellog/proxy.rb
|
91
93
|
- lib/jellog.rb
|
92
94
|
- bin/jellog
|
93
95
|
- spec/spec.opts
|
@@ -95,7 +97,7 @@ files:
|
|
95
97
|
- spec/slogger_spec.rb
|
96
98
|
- spec/jellog_logger_spec.rb
|
97
99
|
- spec/jellog_spec.rb
|
98
|
-
- test/conf.d/
|
100
|
+
- test/conf.d/jellog.rb
|
99
101
|
- test/log_file.log
|
100
102
|
- test/jellytest.log
|
101
103
|
- test/jellytest1.log
|
@@ -103,38 +105,30 @@ files:
|
|
103
105
|
- test/jellogtest1.log
|
104
106
|
- test/jellogtest2.log
|
105
107
|
- test/jellogtest.log
|
106
|
-
|
107
|
-
|
108
|
+
- test/proxy_test.rb
|
109
|
+
homepage: ''
|
110
|
+
licenses:
|
108
111
|
- Open Software Licence v3.0
|
112
|
+
metadata: {}
|
109
113
|
post_install_message: Jellog is now installed. Type 'jellog' for help
|
110
|
-
rdoc_options:
|
114
|
+
rdoc_options:
|
111
115
|
- --main=README.rdoc
|
112
|
-
require_paths:
|
116
|
+
require_paths:
|
113
117
|
- lib
|
114
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
none: false
|
125
|
-
requirements:
|
126
|
-
- - ">="
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
hash: 3
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
version: "0"
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
132
128
|
requirements: []
|
133
|
-
|
134
129
|
rubyforge_project:
|
135
|
-
rubygems_version:
|
130
|
+
rubygems_version: 2.0.7
|
136
131
|
signing_key:
|
137
|
-
specification_version:
|
132
|
+
specification_version: 4
|
138
133
|
summary: Jellog is a simple Ruby logger with a few added extras
|
139
134
|
test_files: []
|
140
|
-
|