RubyApp 0.6.28 → 0.6.29

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby_app/log.rb CHANGED
@@ -5,6 +5,7 @@ require 'facets/string/interpolate'
5
5
  require 'fileutils'
6
6
  require 'logger'
7
7
  require 'socket'
8
+ require 'thread'
8
9
 
9
10
  module RubyApp
10
11
  require 'ruby_app'
@@ -27,7 +28,7 @@ module RubyApp
27
28
  begin
28
29
  return yield
29
30
  ensure
30
- self.log(severity, "#{message} #{Time.now - start}s")
31
+ RubyApp::Log.get.log(severity, "#{message} #{Time.now - start}s")
31
32
  end
32
33
  end
33
34
 
@@ -37,26 +38,35 @@ module RubyApp
37
38
  ensure
38
39
  GC.start
39
40
  count = ObjectSpace.each_object { |item| }
40
- self.log(severity, "#{message} count=#{count}")
41
+ RubyApp::Log.get.log(severity, "#{message} count=#{count}")
41
42
  end
42
43
  end
43
44
 
44
45
  def exception(severity, exception)
45
- self.log(severity, '-' * 80)
46
- self.log(severity, "exception=#{exception.class.inspect} #{exception.message}")
47
- self.log(severity, '-' * 80)
46
+ logger = RubyApp::Log.get
47
+ logger.log(severity, '-' * 80)
48
+ logger.log(severity, "exception=#{exception.class.inspect} #{exception.message}")
49
+ logger.log(severity, '-' * 80)
48
50
  exception.backtrace.each do |line|
49
- self.log(severity, line)
51
+ logger.log(severity, line)
50
52
  end
51
- self.log(severity, '-' * 80)
53
+ logger.log(severity, '-' * 80)
52
54
  end
53
55
 
54
56
  def self.prefix(object, method)
55
57
  return "#{object.is_a?(Class) ? object : object.class}#{object.is_a?(Class) ? '.' : '#'}#{method}"
56
58
  end
57
-
59
+
58
60
  def self.get
59
- ( @@_log ||= nil ) || ( @@_standard_log ||= RubyApp::Log.new($stdout) )
61
+ RubyApp::Log.lock do
62
+ ( @@_log ||= nil ) || ( @@_standard_log ||= RubyApp::Log.new($stdout) )
63
+ end
64
+ end
65
+
66
+ def self.lock
67
+ ( @@_lock ||= ::Mutex.new ).synchronize do
68
+ yield
69
+ end
60
70
  end
61
71
 
62
72
  def self.open!
@@ -77,8 +87,10 @@ module RubyApp
77
87
  end
78
88
 
79
89
  def self.reopen!
80
- RubyApp::Log.close!
81
- RubyApp::Log.open!
90
+ RubyApp::Log.lock do
91
+ RubyApp::Log.close!
92
+ RubyApp::Log.open!
93
+ end
82
94
  end
83
95
 
84
96
  private
@@ -23,6 +23,9 @@ module RubyApp
23
23
  Signal.trap('EXIT') do
24
24
  begin
25
25
  RubyApp::Session.stop_thread!
26
+ RubyApp::Application.destroy!
27
+ RubyApp::Log.close!
28
+ RubyApp::Configuration.unload!
26
29
  rescue => exception
27
30
  RubyApp::Log.exception(RubyApp::Log::ERROR, exception)
28
31
  end
@@ -1,4 +1,4 @@
1
1
  module RubyApp
2
- VERSION = "0.6.28"
2
+ VERSION = "0.6.29"
3
3
  ROOT = File.expand_path(File.dirname(__FILE__))
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubyApp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 28
10
- version: 0.6.28
9
+ - 29
10
+ version: 0.6.29
11
11
  platform: ruby
12
12
  authors:
13
13
  - Frank G. Ficnar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-14 00:00:00 Z
18
+ date: 2012-10-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement