log_runes 1.1.1 → 1.2
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.
- data/lib/log_runes/logger_factory.rb +29 -0
- data/lib/log_runes/version.rb +1 -1
- data/lib/log_runes.rb +5 -1
- metadata +2 -2
- data/lib/log_runes/cronolog.rb +0 -14
@@ -0,0 +1,29 @@
|
|
1
|
+
module LogRunes
|
2
|
+
class LoggerFactory
|
3
|
+
|
4
|
+
|
5
|
+
def self.set(config, opts)
|
6
|
+
|
7
|
+
if Rails.env.development? || Rails.env.test?
|
8
|
+
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
return if opts[:no_cronolog]
|
13
|
+
cronolog_path = opts[:cronolog_path] || '/usr/bin/cronolog'
|
14
|
+
unless File.exists? cronolog_path
|
15
|
+
puts "cronolog missing - reverting to standard logger"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
log_base = opts[:dir] || "#{Rails.root}/log"
|
20
|
+
log_name = opts[:name] || Rails.env
|
21
|
+
crono_cmd = "#{cronolog_path} -S #{log_base}/#{log_name}.log #{log_base}/rot/#{log_name}-%Y-%m-%d.log"
|
22
|
+
l = Logger.new(IO.popen(crono_cmd, "w"))
|
23
|
+
config.logger = opts[:not_tagged] ? l : ActiveSupport::TaggedLogging.new(l)
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/lib/log_runes/version.rb
CHANGED
data/lib/log_runes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "log_runes/
|
1
|
+
require "log_runes/logger_factory"
|
2
2
|
require "log_runes/session_request_tagger"
|
3
3
|
require "log_runes/version"
|
4
4
|
|
@@ -8,6 +8,10 @@ module LogRunes
|
|
8
8
|
SessionRequestTagger.proc
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.set_logger(config, opts={})
|
12
|
+
LoggerFactory.set(config, opts)
|
13
|
+
end
|
14
|
+
|
11
15
|
# Hook Rails init process
|
12
16
|
class Railtie < Rails::Railtie
|
13
17
|
initializer 'log_runes' do |app|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_runes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.2'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -26,7 +26,7 @@ files:
|
|
26
26
|
- README.md
|
27
27
|
- Rakefile
|
28
28
|
- lib/log_runes.rb
|
29
|
-
- lib/log_runes/
|
29
|
+
- lib/log_runes/logger_factory.rb
|
30
30
|
- lib/log_runes/session_request_tagger.rb
|
31
31
|
- lib/log_runes/version.rb
|
32
32
|
- log_runes.gemspec
|
data/lib/log_runes/cronolog.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module LogRunes
|
2
|
-
class Cronolog
|
3
|
-
|
4
|
-
def self.setup(config, log_base)
|
5
|
-
unless File.exists? '/usr/bin/cronolog'
|
6
|
-
puts "cronolog missing - reverting to standard logger"
|
7
|
-
return
|
8
|
-
end
|
9
|
-
crono_cmd = "/usr/bin/cronolog -S #{log_base}/#{Rails.env}.log #{log_base}/rot/#{Rails.env}-%Y-%m-%d.log"
|
10
|
-
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(IO.popen(crono_cmd, "w")))
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|