sappho-basics 0.0.2 → 0.0.3

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.
@@ -13,10 +13,26 @@ module Sappho
13
13
 
14
14
  include Singleton
15
15
 
16
+ LOG_LEVELS = {
17
+ 'debug' => Logger::DEBUG,
18
+ 'info' => Logger::INFO,
19
+ 'warn' => Logger::WARN,
20
+ 'error' => Logger::ERROR,
21
+ 'fatal' => Logger::FATAL,
22
+ 'unknown' => Logger::UNKNOWN
23
+ }
24
+ LOG_DETAIL = {
25
+ 'message' => proc { |severity, datetime, progname, message| "#{message}\n" }
26
+ }
27
+
16
28
  def initialize
17
29
  @mutex = Mutex.new
18
- @log = Logger.new $stdout
19
- @log.level = ENV['application.log.level'] == 'debug' ? Logger::DEBUG : Logger::INFO
30
+ filename = ENV['application.log.filename']
31
+ @log = Logger.new(filename ? open(filename, 'a') : $stdout)
32
+ level = ENV['application.log.level']
33
+ @log.level = LOG_LEVELS.has_key?(level) ? LOG_LEVELS[level] : Logger::INFO
34
+ detail = ENV['application.log.detail']
35
+ @log.formatter = LOG_DETAIL[detail] if LOG_DETAIL.has_key?(detail)
20
36
  end
21
37
 
22
38
  def info message
@@ -5,7 +5,7 @@
5
5
 
6
6
  module Sappho
7
7
  NAME = 'sappho-basics'
8
- VERSION = '0.0.2'
8
+ VERSION = '0.0.3'
9
9
  AUTHORS = ['Andrew Heald']
10
10
  EMAILS = ['andrew@heald.co.uk']
11
11
  HOMEPAGE = 'https://github.com/sappho/sappho-basics/wiki'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sappho-basics
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Heald