pyer-logger 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/pyer/logger.rb +53 -31
  3. metadata +19 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4894005ac53da8f7ef99404bb956084a6597b74a
4
- data.tar.gz: a1f12c6a90d1f0b40119569ea4e644f0cacf4179
2
+ SHA256:
3
+ metadata.gz: 1239e84aed003d02e0a53e220105bfa585d010203fdd780e3f7a971a5ca7452d
4
+ data.tar.gz: 3dbc619afd00da79ebc75f319039d116460ed30893ab3c294de61971a1c662d5
5
5
  SHA512:
6
- metadata.gz: 1e2d24fc6088ae0e165f7c5161e3f1a503e90134669dfb071974676df6d578079691a67e5ee7bd393aad16828c3245afaaff875c7daf87b89677551add4af111
7
- data.tar.gz: ad1bdecdf44243373a05c67c52cddd8eea57060a027bd43770bdf1732ba5104b4071027c86c8d2da4cd82e8e84f4d3182a045f754b9a3213d3e4a64f96d6ef5c
6
+ metadata.gz: 2c91ef693c7a0c6b33573a4a131fdbfb07c50dcd7621a5eeecf8fc45f9310f87880944ae5722d968d23b82dfd439666bef02d31a291fae5a2bb7d1443cd89e84
7
+ data.tar.gz: 56bac97b192dcc5f394b993112aae2249b8ef2362f85fdfa6c40dc11061834f296cf5d6676a4fb0d5f1656d4b6cceb54a7bb3c651e53d5afc60c64771e7d1513
data/lib/pyer/logger.rb CHANGED
@@ -1,59 +1,78 @@
1
1
  # encoding: UTF-8
2
2
  #
3
- # == Description
4
- #
5
- # The Logger class provides a simple logging utility.
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.
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.
10
5
  #
6
+ # The messages will have varying levels reflecting their varying importance.
11
7
  # The levels, and their meanings, are:
12
- # +ERROR+:: an error condition
13
- # +WARN +:: a warning
14
- # +INFO +:: generic (useful) information about system operation
15
- # +DEBUG+:: low-level information for developers
8
+ # 1. DEBUG : low-level information for developers
9
+ # 2. INFO : generic (useful) information about system operation
10
+ # 3. WARN : a warning
11
+ # 4. ERROR : an error condition
16
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
16
  #
21
- # == HOWTOs
22
- #
23
- # === How to create a logger
17
+ # == How to create a logger ?
24
18
  #
25
19
  # 1. Create a logger which logs messages to STDERR/STDOUT.
26
- # logger = Logger.new(STDOUT)
27
- # logger = Logger.new(STDERR)
20
+ # log = Logger.new(STDOUT, self.class)
21
+ # log = Logger.new(STDERR, self.class)
28
22
  #
29
23
  # 2. Create a logger for the file which has the specified name.
30
- # logger = Logger.new('logfile.log')
24
+ # log = Logger.new('logfile.log', self.class)
31
25
  #
32
- # === How to log a message
26
+ # 3. Create a logger which logs messages to a string.
27
+ # log = Logger.new(STRING, self.class)
33
28
  #
34
- # Notice the different methods (+fatal+, +error+, +warn+, +info+, +debug+)
35
- # being used to log messages of various levels.
36
- # Messages lower than logger.level are not emitted.
29
+ # Notice that self.class argument prints the class name of the caller object.
37
30
  #
38
- # 1. Message in block.
31
+ # == How to log a message ?
32
+ #
33
+ # Notice the different methods being used to log messages of various levels.
34
+ #
35
+ # Messages lower than log.level are not sent to output.
36
+ #
37
+ # Ranking: DEBUG < INFO < WARN < ERROR
38
+ #
39
+ # Default log.level is DEBUG. That means all messages are emitted.
40
+ #
41
+ # 1. Debug message
42
+ # log.debug "dev info"
39
43
  #
40
- # logger.error { "Argument 'foo' not given." }
44
+ # 2. Information
45
+ # log.info "some informations"
46
+ #
47
+ # 3. Warning message
48
+ # log.warn "a warning message"
49
+ #
50
+ # 4. Error message
51
+ # log.error "error is #{ @code }"
52
+ #
53
+ # Messages are provided in a string or in a block, or both.
54
+ #
55
+ # 1. Message in block.
56
+ # log.error { "Argument 'foo' not given." }
41
57
  #
42
58
  # 2. Message as a string.
59
+ # log.error "Argument #{ @foo } mismatch."
60
+ #
61
+ # 3. Both arguments
62
+ # log.error("Argument ") { "#{ @foo } mismatch." }
43
63
  #
44
- # logger.error "Argument #{ @foo } mismatch."
64
+ # == How to set severity level ?
45
65
  #
46
- # === How to set severity level
66
+ # log.level = INFO
47
67
  #
48
- # logger.level = Logger::INFO
68
+ # == How to close a logger ?
49
69
  #
50
- # DEBUG < INFO < WARN < ERROR
70
+ # log.close
51
71
  #
52
- # === How to close a logger
72
+ # == Installation
53
73
  #
54
- # logger.close
74
+ # gem install pyer-logger
55
75
  #
56
- # All my tools are in module Pyer
57
76
  module Pyer
58
77
  require 'stringio'
59
78
 
@@ -192,7 +211,10 @@ module Pyer
192
211
  end
193
212
  end
194
213
 
195
- # Backward-compatible alias
214
+ # == Aliases
215
+ #
216
+ # Aliases are made to make life simpler.
217
+ #
196
218
  Logger = Pyer::Logger
197
219
  STRING = Pyer::Logger::STRING
198
220
 
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyer-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
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-28 00:00:00.000000000 Z
11
+ date:
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: stringio
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: '12.3'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: '12.3'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: minitest
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -65,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
79
  - !ruby/object:Gem::Version
66
80
  version: '0'
67
81
  requirements: []
68
- rubyforge_project:
69
- rubygems_version: 2.4.5
82
+ rubygems_version: 3.1.2
70
83
  signing_key:
71
84
  specification_version: 4
72
85
  summary: Logger