pyer-logger 1.0.0 → 1.0.1
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/lib/pyer/logger.rb +69 -46
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1fb8264eb6b552bd6372448e9a4892081592355
|
4
|
+
data.tar.gz: 30cbb717001f157d12c927f06c9df5417c26f0b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a795511e7737515fcf133e42981f5da3728e05c77ea32b40987a90516d2c5540cd75bb2be3c5a1756f3ec74c66ece4bf127b7f5d461337adb133d714b81ebf7c
|
7
|
+
data.tar.gz: bfc035a8d4e80dfc68ca9dab9291c32c3c4bc755365448f57cc37bbb09decfdc9cdcc89665e176cc8e34592c2bc1675c040101d7df936eec2722fa85ec2abfd0
|
data/lib/pyer/logger.rb
CHANGED
@@ -1,59 +1,82 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# You create a Logger object (output to a file, STDOUT or STDERR).
|
8
|
-
# The messages will have varying levels (+info+, +error+, etc),
|
9
|
-
# reflecting their varying importance.
|
10
|
-
#
|
3
|
+
# This Logger class provides a simple logging utility for Ruby applications.
|
4
|
+
# Log messages are sent to stdout, stderr, a file or a string by a Logger object.
|
5
|
+
#
|
6
|
+
# The messages will have varying levels reflecting their varying importance.
|
11
7
|
# The levels, and their meanings, are:
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
8
|
+
# * ERROR : an error condition
|
9
|
+
# * WARN : a warning
|
10
|
+
# * INFO : generic (useful) information about system operation
|
11
|
+
# * DEBUG : low-level information for developers
|
12
|
+
#
|
17
13
|
# So each message has a level, and the Logger itself has a level, which acts
|
18
14
|
# as a filter, so you can control the amount of information emitted from the
|
19
15
|
# logger without having to remove actual messages.
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
16
|
+
#
|
17
|
+
# How to create a logger ?
|
18
|
+
# ------------------------
|
19
|
+
#
|
25
20
|
# 1. Create a logger which logs messages to STDERR/STDOUT.
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
21
|
+
# log = Logger.new(STDOUT, self.class)
|
22
|
+
# log = Logger.new(STDERR, self.class)
|
23
|
+
#
|
29
24
|
# 2. Create a logger for the file which has the specified name.
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
25
|
+
# log = Logger.new('logfile.log', self.class)
|
26
|
+
#
|
27
|
+
# 3. Create a logger which logs messages to a string.
|
28
|
+
# log = Logger.new(STRING, self.class)
|
29
|
+
#
|
30
|
+
# Notice that self.class argument prints the class name of the caller object.
|
31
|
+
#
|
32
|
+
# How to log a message ?
|
33
|
+
# ----------------------
|
34
|
+
#
|
35
|
+
# Notice the different methods being used to log messages of various levels.
|
36
|
+
# Messages lower than log.level are not sent to output.
|
37
|
+
#
|
38
|
+
# Default log.level is DEBUG. That means all messages are emitted.
|
39
|
+
#
|
40
|
+
# DEBUG < INFO < WARN < ERROR
|
41
|
+
#
|
42
|
+
# 1. log.error "error is #{ @code }"
|
43
|
+
#
|
44
|
+
# 2. log.warn "a warning message"
|
45
|
+
#
|
46
|
+
# 3. log.info "some informations"
|
47
|
+
#
|
48
|
+
# 4. log.debug "dev info"
|
49
|
+
#
|
50
|
+
# Messages are provided in a string or in a block, or both.
|
51
|
+
#
|
38
52
|
# 1. Message in block.
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
53
|
+
#
|
54
|
+
# log.error { "Argument 'foo' not given." }
|
55
|
+
#
|
42
56
|
# 2. Message as a string.
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
+
#
|
58
|
+
# log.error "Argument #{ @foo } mismatch."
|
59
|
+
#
|
60
|
+
# 3. Both arguments
|
61
|
+
#
|
62
|
+
# log.error("Argument ") { "#{ @foo } mismatch." }
|
63
|
+
#
|
64
|
+
# How to set severity level ?
|
65
|
+
# ---------------------------
|
66
|
+
#
|
67
|
+
# log.level = INFO
|
68
|
+
#
|
69
|
+
# How to close a logger ?
|
70
|
+
# -----------------------
|
71
|
+
#
|
72
|
+
# log.close
|
73
|
+
#
|
74
|
+
#
|
75
|
+
# Installation
|
76
|
+
# ------------
|
77
|
+
#
|
78
|
+
# gem install pyer-options
|
79
|
+
#
|
57
80
|
module Pyer
|
58
81
|
require 'stringio'
|
59
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pyer-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre BAZONNARD
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|