Moved to framework logger object.
This commit is contained in:
parent
0225ba1cdf
commit
d9938f59c6
6 changed files with 35 additions and 40 deletions
|
@ -182,7 +182,7 @@ returns
|
|||
if self.class.column_names.include? 'updated_by_id'
|
||||
if UserInfo.current_user_id
|
||||
if self.updated_by_id && self.updated_by_id != UserInfo.current_user_id
|
||||
puts "NOTICE create - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
|
||||
logger.info "NOTICE create - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
|
||||
end
|
||||
self.updated_by_id = UserInfo.current_user_id
|
||||
end
|
||||
|
@ -190,7 +190,7 @@ returns
|
|||
if self.class.column_names.include? 'created_by_id'
|
||||
if UserInfo.current_user_id
|
||||
if self.created_by_id && self.created_by_id != UserInfo.current_user_id
|
||||
puts "NOTICE create - self.created_by_id is different: #{self.created_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
|
||||
logger.info "NOTICE create - self.created_by_id is different: #{self.created_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
|
||||
end
|
||||
self.created_by_id = UserInfo.current_user_id
|
||||
end
|
||||
|
@ -426,7 +426,7 @@ class OwnModel < ApplicationModel
|
|||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
puts "#{ self.class.name }.find(#{ self.id }) notify created " + self.created_at.to_s
|
||||
logger.debug "#{ self.class.name }.find(#{ self.id }) notify created " + self.created_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Sessions.broadcast(
|
||||
|
@ -454,7 +454,7 @@ class OwnModel < ApplicationModel
|
|||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
puts "#{ self.class.name }.find(#{ self.id }) notify UPDATED " + self.updated_at.to_s
|
||||
logger.debug "#{ self.class.name }.find(#{ self.id }) notify UPDATED " + self.updated_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Sessions.broadcast(
|
||||
|
@ -481,7 +481,7 @@ class OwnModel < ApplicationModel
|
|||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
puts "#{ self.class.name }.find(#{ self.id }) notify DESTOY " + self.updated_at.to_s
|
||||
logger.debug "#{ self.class.name }.find(#{ self.id }) notify DESTOY " + self.updated_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Sessions.broadcast(
|
||||
|
@ -934,7 +934,7 @@ check string/varchar size and cut them if needed
|
|||
if column && limit
|
||||
current_length = attribute[1].to_s.length
|
||||
if limit < current_length
|
||||
puts "WARNING: cut string because of database length #{self.class.to_s}.#{attribute[0]}(#{limit} but is #{current_length}:#{attribute[1].to_s})"
|
||||
logger.info "WARNING: cut string because of database length #{self.class.to_s}.#{attribute[0]}(#{limit} but is #{current_length}:#{attribute[1].to_s})"
|
||||
self[ attribute[0] ] = attribute[1][ 0, limit ]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ class Package < ApplicationModel
|
|||
end
|
||||
if data[:output]
|
||||
location = data[:output] + '/' + package.elements["zpm/name"].text + '-' + package.elements["zpm/version"].text + '.zpm'
|
||||
puts "NOTICE: writting package to '#{location}'"
|
||||
logger.info "NOTICE: writting package to '#{location}'"
|
||||
file = File.new( location, 'wb' )
|
||||
file.write( package.to_s )
|
||||
file.close
|
||||
|
@ -67,12 +67,12 @@ class Package < ApplicationModel
|
|||
# link files
|
||||
Dir.glob( @@root + '/**/*' ) do |entry|
|
||||
if File.symlink?( entry)
|
||||
puts "unlink: #{entry}"
|
||||
logger.info "unlink: #{entry}"
|
||||
File.delete( entry )
|
||||
end
|
||||
backup_file = entry + '.link_backup'
|
||||
if File.exists?( backup_file )
|
||||
puts "Restore backup file of #{backup_file} -> #{entry}."
|
||||
logger.info "Restore backup file of #{backup_file} -> #{entry}."
|
||||
File.rename( backup_file, entry )
|
||||
end
|
||||
end
|
||||
|
@ -87,7 +87,7 @@ class Package < ApplicationModel
|
|||
if package == false
|
||||
raise "Can't link package, '#{package_base_dir}' is no package source directory!"
|
||||
end
|
||||
puts package.inspect
|
||||
logger.debug package.inspect
|
||||
return package
|
||||
end
|
||||
|
||||
|
@ -109,13 +109,13 @@ class Package < ApplicationModel
|
|||
dest = @@root + '/' + file
|
||||
|
||||
if File.symlink?( dest.to_s )
|
||||
puts "Unlink file: #{dest.to_s}"
|
||||
logger.info "Unlink file: #{dest.to_s}"
|
||||
File.delete( dest.to_s )
|
||||
end
|
||||
|
||||
backup_file = dest.to_s + '.link_backup'
|
||||
if File.exists?( backup_file )
|
||||
puts "Restore backup file of #{backup_file} -> #{dest.to_s}."
|
||||
logger.info "Restore backup file of #{backup_file} -> #{dest.to_s}."
|
||||
File.rename( backup_file, dest.to_s )
|
||||
end
|
||||
end
|
||||
|
@ -137,7 +137,7 @@ class Package < ApplicationModel
|
|||
|
||||
# ignore files
|
||||
if file =~ /^README/
|
||||
puts "NOTICE: Ignore #{file}"
|
||||
logger.info "NOTICE: Ignore #{file}"
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -146,7 +146,7 @@ class Package < ApplicationModel
|
|||
|
||||
if File.directory?( entry.to_s )
|
||||
if !File.exists?( dest.to_s )
|
||||
puts "Create dir: #{dest.to_s}"
|
||||
logger.info "Create dir: #{dest.to_s}"
|
||||
FileUtils.mkdir_p( dest.to_s )
|
||||
end
|
||||
end
|
||||
|
@ -156,7 +156,7 @@ class Package < ApplicationModel
|
|||
if File.exists?( backup_file )
|
||||
raise "Can't link #{entry.to_s} -> #{dest.to_s}, destination and .link_backup already exists!"
|
||||
else
|
||||
puts "Create backup file of #{dest.to_s} -> #{backup_file}."
|
||||
logger.info "Create backup file of #{dest.to_s} -> #{backup_file}."
|
||||
File.rename( dest.to_s, backup_file )
|
||||
end
|
||||
end
|
||||
|
@ -165,7 +165,7 @@ class Package < ApplicationModel
|
|||
if File.symlink?( dest.to_s )
|
||||
File.delete( dest.to_s )
|
||||
end
|
||||
puts "Link file: #{entry.to_s} -> #{dest.to_s}"
|
||||
logger.info "Link file: #{entry.to_s} -> #{dest.to_s}"
|
||||
File.symlink( entry.to_s, dest.to_s )
|
||||
end
|
||||
end
|
||||
|
@ -325,14 +325,14 @@ class Package < ApplicationModel
|
|||
end
|
||||
|
||||
def self._parse(xml)
|
||||
# puts xml.inspect
|
||||
logger.debug xml.inspect
|
||||
begin
|
||||
package = REXML::Document.new( xml )
|
||||
rescue => e
|
||||
puts 'ERROR: ' + e.inspect
|
||||
return
|
||||
end
|
||||
# puts package.inspect
|
||||
logger.debug package.inspect
|
||||
return package
|
||||
end
|
||||
|
||||
|
@ -383,7 +383,7 @@ class Package < ApplicationModel
|
|||
# rename existing file
|
||||
if File.exist?( location )
|
||||
backup_location = location + '.save'
|
||||
puts "NOTICE: backup old file '#{location}' to #{backup_location}"
|
||||
logger.info "NOTICE: backup old file '#{location}' to #{backup_location}"
|
||||
File.rename( location, backup_location )
|
||||
end
|
||||
|
||||
|
@ -403,7 +403,7 @@ class Package < ApplicationModel
|
|||
|
||||
# install file
|
||||
begin
|
||||
puts "NOTICE: install '#{location}' (#{permission})"
|
||||
logger.info "NOTICE: install '#{location}' (#{permission})"
|
||||
file = File.new( location, 'wb' )
|
||||
file.write( data )
|
||||
file.close
|
||||
|
@ -418,7 +418,7 @@ class Package < ApplicationModel
|
|||
location = @@root + '/' + file
|
||||
|
||||
# install file
|
||||
puts "NOTICE: uninstall '#{location}'"
|
||||
logger.info "NOTICE: uninstall '#{location}'"
|
||||
if File.exist?( location )
|
||||
File.delete( location )
|
||||
end
|
||||
|
@ -426,7 +426,7 @@ class Package < ApplicationModel
|
|||
# rename existing file
|
||||
backup_location = location + '.save'
|
||||
if File.exist?( backup_location )
|
||||
puts "NOTICE: restore old file '#{backup_location}' to #{location}"
|
||||
logger.info "NOTICE: restore old file '#{backup_location}' to #{location}"
|
||||
File.rename( backup_location, location )
|
||||
end
|
||||
|
||||
|
@ -474,7 +474,7 @@ class Package < ApplicationModel
|
|||
if direction == 'reverse'
|
||||
done = Package::Migration.where( :name => package.underscore, :version => version ).first
|
||||
next if !done
|
||||
puts "NOTICE: down package migration '#{migration}'"
|
||||
logger.info "NOTICE: down package migration '#{migration}'"
|
||||
load "#{location}/#{migration}"
|
||||
classname = name.camelcase
|
||||
Kernel.const_get(classname).down
|
||||
|
@ -487,7 +487,7 @@ class Package < ApplicationModel
|
|||
else
|
||||
done = Package::Migration.where( :name => package.underscore, :version => version ).first
|
||||
next if done
|
||||
puts "NOTICE: up package migration '#{migration}'"
|
||||
logger.info "NOTICE: up package migration '#{migration}'"
|
||||
load "#{location}/#{migration}"
|
||||
classname = name.camelcase
|
||||
Kernel.const_get(classname).up
|
||||
|
|
|
@ -8,7 +8,7 @@ class Scheduler < ApplicationModel
|
|||
|
||||
jobs_started = {}
|
||||
while true
|
||||
puts "Scheduler running (runner #{runner} of #{runner_count})..."
|
||||
logger.info "Scheduler running (runner #{runner} of #{runner_count})..."
|
||||
|
||||
# reconnect in case db connection is lost
|
||||
begin
|
||||
|
@ -29,7 +29,7 @@ class Scheduler < ApplicationModel
|
|||
end
|
||||
|
||||
def self.start_job( job, runner, runner_count )
|
||||
puts "started job thread for '#{job.name}' (#{job.method})..."
|
||||
logger.info "started job thread for '#{job.name}' (#{job.method})..."
|
||||
sleep 4
|
||||
|
||||
Thread.new {
|
||||
|
@ -56,7 +56,7 @@ class Scheduler < ApplicationModel
|
|||
# raise "Exception from thread"
|
||||
job.pid = ''
|
||||
job.save
|
||||
puts " ...stopped thread for '#{job.method}'"
|
||||
logger.info " ...stopped thread for '#{job.method}'"
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -66,7 +66,7 @@ class Scheduler < ApplicationModel
|
|||
job.last_run = Time.now
|
||||
job.pid = Thread.current.object_id
|
||||
job.save
|
||||
puts "execute #{job.method} (runner #{runner} of #{runner_count}, try_count #{try_count})..."
|
||||
logger.info "execute #{job.method} (runner #{runner} of #{runner_count}, try_count #{try_count})..."
|
||||
eval job.method()
|
||||
rescue => e
|
||||
puts "execute #{job.method} (runner #{runner} of #{runner_count}, try_count #{try_count}) exited with error #{ e.inspect }"
|
||||
|
@ -84,7 +84,7 @@ class Scheduler < ApplicationModel
|
|||
# reset error counter if to old
|
||||
if try_run_time + ( 60 * 5 ) < Time.now
|
||||
try_count = 0
|
||||
end
|
||||
end
|
||||
try_run_time = Time.now
|
||||
|
||||
# restart job again
|
||||
|
@ -98,7 +98,7 @@ class Scheduler < ApplicationModel
|
|||
|
||||
def self.worker
|
||||
wait = 10
|
||||
puts "*** Starting worker #{Delayed::Job.to_s}"
|
||||
logger.info "*** Starting worker #{Delayed::Job.to_s}"
|
||||
|
||||
loop do
|
||||
result = nil
|
||||
|
@ -113,7 +113,7 @@ class Scheduler < ApplicationModel
|
|||
|
||||
if count.zero?
|
||||
sleep(wait)
|
||||
puts "*** worker loop"
|
||||
logger.info "*** worker loop"
|
||||
else
|
||||
printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last]
|
||||
end
|
||||
|
|
|
@ -42,6 +42,7 @@ class Setting < ApplicationModel
|
|||
end
|
||||
setting.state = { :value => value }
|
||||
setting.save
|
||||
logger.info "Setting.set() name:#{name}, value:#{value.inspect}"
|
||||
end
|
||||
|
||||
def self.get(name)
|
||||
|
|
|
@ -403,7 +403,7 @@ returns
|
|||
|
||||
# find file
|
||||
list = Store.list( :object => 'User::Image', :o_id => self.id )
|
||||
puts list.inspect
|
||||
logger.debug list.inspect
|
||||
if list && list[0]
|
||||
file = Store.find( list[0] )
|
||||
result = {
|
||||
|
@ -492,7 +492,7 @@ returns
|
|||
if self.email
|
||||
hash = Digest::MD5.hexdigest(self.email)
|
||||
self.image_source = "http://www.gravatar.com/avatar/#{hash}?s=48&d=404"
|
||||
#puts "#{self.email}: http://www.gravatar.com/avatar/#{hash}?s=48&d=404"
|
||||
logger.debug "#{self.email}: #{self.image_source}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,14 +59,8 @@ module NotificationFactory
|
|||
|
||||
def self.send(data)
|
||||
sender = Setting.get('notification_sender')
|
||||
<<<<<<< HEAD
|
||||
Rails.logger.info "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]}"
|
||||
Rails.logger.info "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]} (from #{sender})"
|
||||
Channel::EmailSend.new.send(
|
||||
=======
|
||||
imap = Channel::IMAP.new
|
||||
Rails.logger.info "NOTICE: SEND NOTIFICATION TO: #{data[:recipient][:email]}"
|
||||
message = imap.send(
|
||||
>>>>>>> 5e22499e44225c831661087b68de154deafef5c6
|
||||
{
|
||||
# :in_reply_to => self.in_reply_to,
|
||||
:from => sender,
|
||||
|
|
Loading…
Reference in a new issue