lib/bixby-common/util/log.rb in bixby-common-0.4.7 vs lib/bixby-common/util/log.rb in bixby-common-0.4.8
- old
+ new
@@ -43,10 +43,21 @@
pattern = opts.delete(:pattern) || '%.1l, [%d] %5l -- %c:%L: %m\n'
layout = Logging.layouts.pattern(:pattern => pattern)
opts[:filename] ||= Bixby.path("var", "bixby-agent.log")
- FileUtils.mkdir_p(File.dirname(opts[:filename]))
+ log_dir = File.dirname(opts[:filename])
+ FileUtils.mkdir_p(log_dir)
+
+ # make sure we have the correct permissions
+ if Process.uid == 0 then
+ if !File.exists? opts[:filename] then
+ FileUtils.touch([opts[:filename], opts[:filename] + ".age"])
+ end
+ File.chmod(0777, log_dir)
+ File.chmod(0777, opts[:filename])
+ File.chmod(0777, opts[:filename] + ".age")
+ end
# configure stdout appender (used in debug modes, etc)
Logging.color_scheme( 'bright',
:levels => {
:info => :green,