Skip to content

Commit ed9dc89

Browse files
committed
Refactor background daemon logging to use Rails.root for log file paths
* Removed the dedicated log directory creation for background daemon tasks. * Updated log file path construction to utilize Rails.root for consistency and clarity.
1 parent 4e4ff0b commit ed9dc89

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

‎script/background_daemon‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ require 'logger'
1212
root_dir = File.expand_path('../', File.dirname(__FILE__))
1313
pid_dir = root_dir + '/tmp/pids'
1414
log_dir = root_dir + '/log'
15-
background_daemon_log_dir = root_dir + '/logs/background_daemon'
1615
FileUtils.mkdir_p(pid_dir)
1716
FileUtils.mkdir_p(log_dir)
18-
FileUtils.mkdir_p(background_daemon_log_dir)
1917

2018
def exception_to_str(e)
2119
e.message + "\n" + e.backtrace.join("\n from ")
@@ -45,7 +43,7 @@ Rails.logger.info 'Starting background_daemon'
4543
processes = BackgroundTaskRegistry.all_tasks.map do |task|
4644
Process.fork do
4745
# Create individual logger for this task
48-
task_log_file = File.join(background_daemon_log_dir, "#{task.class.name.underscore}.log")
46+
task_log_file = Rails.root.join('log', 'background_daemon', "#{task.class.name.underscore}.log")
4947
task_logger = Logger.new(task_log_file)
5048
task_logger.formatter = proc do |severity, datetime, progname, msg|
5149
"#{datetime}: #{severity} - #{msg}\n"

0 commit comments

Comments
 (0)