sappho-basics 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -18,8 +18,7 @@ module Sappho
|
|
18
18
|
'info' => Logger::INFO,
|
19
19
|
'warn' => Logger::WARN,
|
20
20
|
'error' => Logger::ERROR,
|
21
|
-
'fatal' => Logger::FATAL
|
22
|
-
'unknown' => Logger::UNKNOWN
|
21
|
+
'fatal' => Logger::FATAL
|
23
22
|
}
|
24
23
|
LOG_DETAIL = {
|
25
24
|
'message' => proc { |severity, datetime, progname, message| "#{message}\n" }
|
@@ -35,18 +34,18 @@ module Sappho
|
|
35
34
|
@log.formatter = LOG_DETAIL[detail] if LOG_DETAIL.has_key?(detail)
|
36
35
|
end
|
37
36
|
|
38
|
-
def
|
37
|
+
def debug message
|
39
38
|
@mutex.synchronize do
|
40
|
-
@log.
|
39
|
+
@log.debug message
|
41
40
|
$stdout.flush
|
42
|
-
end if @log.
|
41
|
+
end if @log.debug?
|
43
42
|
end
|
44
43
|
|
45
|
-
def
|
44
|
+
def info message
|
46
45
|
@mutex.synchronize do
|
47
|
-
@log.
|
46
|
+
@log.info message
|
48
47
|
$stdout.flush
|
49
|
-
end if @log.
|
48
|
+
end if @log.info?
|
50
49
|
end
|
51
50
|
|
52
51
|
def warn message
|
@@ -64,6 +63,14 @@ module Sappho
|
|
64
63
|
end if @log.error?
|
65
64
|
end
|
66
65
|
|
66
|
+
def fatal error
|
67
|
+
@mutex.synchronize do
|
68
|
+
@log.fatal "fatal error! #{error.message}"
|
69
|
+
error.backtrace.each { |error| @log.fatal error }
|
70
|
+
$stdout.flush
|
71
|
+
end if @log.fatal?
|
72
|
+
end
|
73
|
+
|
67
74
|
def debug?
|
68
75
|
@log.debug?
|
69
76
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# See https://github.com/sappho/sappho-basics/wiki for project documentation.
|
2
|
+
# This software is licensed under the GNU Affero General Public License, version 3.
|
3
|
+
# See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
|
4
|
+
# Copyright 2012 Andrew Heald.
|
5
|
+
|
6
|
+
require 'singleton'
|
7
|
+
require 'sappho-basics/auto_flush_log'
|
8
|
+
|
9
|
+
module Sappho
|
10
|
+
|
11
|
+
class ModuleRegister
|
12
|
+
|
13
|
+
include Singleton
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@modules = { :log => AutoFlushLog.instance }
|
17
|
+
end
|
18
|
+
|
19
|
+
def set name, mod
|
20
|
+
@modules[name] = mod
|
21
|
+
end
|
22
|
+
|
23
|
+
def get name
|
24
|
+
@modules[name]
|
25
|
+
end
|
26
|
+
|
27
|
+
def set? name
|
28
|
+
@modules.has_key? name
|
29
|
+
end
|
30
|
+
|
31
|
+
def shutdown
|
32
|
+
each { |mod| mod.shutdown }
|
33
|
+
end
|
34
|
+
|
35
|
+
def each
|
36
|
+
@modules.each do |name, mod|
|
37
|
+
begin
|
38
|
+
yield mod
|
39
|
+
rescue
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Heald
|
@@ -45,6 +45,7 @@ extra_rdoc_files: []
|
|
45
45
|
|
46
46
|
files:
|
47
47
|
- lib/sappho-basics/auto_flush_log.rb
|
48
|
+
- lib/sappho-basics/module_register.rb
|
48
49
|
- lib/sappho-basics/version.rb
|
49
50
|
homepage: https://github.com/sappho/sappho-basics/wiki
|
50
51
|
licenses: []
|