lib/rest-ftp-daemon/worker.rb in rest-ftp-daemon-0.222.0 vs lib/rest-ftp-daemon/worker.rb in rest-ftp-daemon-0.230.0
- old
+ new
@@ -8,18 +8,19 @@
end
def initialize wid
# Logger
@logger = RestFtpDaemon::LoggerPool.instance.get :workers
+ @log_worker_status_changes = true
# Worker name
@wid = wid
# Set thread context
Thread.current.thread_variable_set :wid, wid
Thread.current.thread_variable_set :started_at, Time.now
- worker_status :starting
+ worker_status WORKER_STATUS_STARTING
end
protected
def log_context
@@ -38,12 +39,19 @@
sleep 1
end
end
end
- def worker_status status
+ def worker_status status, extra = ""
+ # Update thread variables
Thread.current.thread_variable_set :status, status
Thread.current.thread_variable_set :updted_at, Time.now
+
+ # Nothin' to log if "silent"
+ return unless @log_worker_status_changes
+
+ # Log this status change
+ log_info "worker: #{status} #{extra}"
end
def worker_jid jid
Thread.current.thread_variable_set :jid, jid
Thread.current.thread_variable_set :updted_at, Time.now