Fixed logger namespace.

This commit is contained in:
Martin Edenhofer 2015-05-04 21:34:04 +02:00
parent e0c7e91fd6
commit 9ce362cabe
5 changed files with 39 additions and 39 deletions

View file

@ -15,7 +15,7 @@ class Channel::Facebook
def send def send
logger.debug('face!!!!!!!!!!!!!!') Rails.logger.debug('face!!!!!!!!!!!!!!')
graph_api = Koala::Facebook::API.new( graph_api = Koala::Facebook::API.new(
'AAACqTciZAPsQBAHO9DbM333y2DcL5kccHyIObZB7WhaZBVUXUIeBNChkshvShCgiN6uwZC3r3l4cDvAZAPTArNIkemEraojzN1veNPZBADQAZDZD' 'AAACqTciZAPsQBAHO9DbM333y2DcL5kccHyIObZB7WhaZBVUXUIeBNChkshvShCgiN6uwZC3r3l4cDvAZAPTArNIkemEraojzN1veNPZBADQAZDZD'
) )

View file

@ -12,7 +12,7 @@ class Channel::IMAP < Channel::EmailParser
port = 143 port = 143
end end
logger.info "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})" Rails.logger.info "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"
# on check, reduce open_timeout to have faster probing # on check, reduce open_timeout to have faster probing
timeout = 12 timeout = 12
@ -42,11 +42,11 @@ class Channel::IMAP < Channel::EmailParser
@imap.select( channel[:options][:folder] ) @imap.select( channel[:options][:folder] )
end end
if check_type == 'check' if check_type == 'check'
logger.info 'check only mode, fetch no emails' Rails.logger.info 'check only mode, fetch no emails'
disconnect disconnect
return return
elsif check_type == 'verify' elsif check_type == 'verify'
logger.info "verify mode, fetch no emails #{verify_string}" Rails.logger.info "verify mode, fetch no emails #{verify_string}"
end end
message_ids = @imap.search(['ALL']) message_ids = @imap.search(['ALL'])
@ -60,14 +60,14 @@ class Channel::IMAP < Channel::EmailParser
message_ids.each do |message_id| message_ids.each do |message_id|
count += 1 count += 1
logger.info " - message #{count.to_s}/#{count_all.to_s}" Rails.logger.info " - message #{count.to_s}/#{count_all.to_s}"
#logger.info msg.to_s #Rails.logger.info msg.to_s
# check for verify message # check for verify message
if check_type == 'verify' if check_type == 'verify'
subject = @imap.fetch(message_id, 'ENVELOPE')[0].attr['ENVELOPE'].subject subject = @imap.fetch(message_id, 'ENVELOPE')[0].attr['ENVELOPE'].subject
if subject && subject =~ /#{verify_string}/ if subject && subject =~ /#{verify_string}/
logger.info " - verify email #{verify_string} found" Rails.logger.info " - verify email #{verify_string} found"
@imap.store(message_id, '+FLAGS', [:Deleted]) @imap.store(message_id, '+FLAGS', [:Deleted])
@imap.expunge() @imap.expunge()
disconnect disconnect
@ -85,9 +85,9 @@ class Channel::IMAP < Channel::EmailParser
@imap.expunge() @imap.expunge()
disconnect disconnect
if count == 0 if count == 0
logger.info ' - no message' Rails.logger.info ' - no message'
end end
logger.info 'done' Rails.logger.info 'done'
end end
def disconnect def disconnect

View file

@ -2,7 +2,7 @@
class Channel::MailStdin < Channel::EmailParser class Channel::MailStdin < Channel::EmailParser
def initialize def initialize
logger.info 'read main from STDIN' Rails.logger.info 'read main from STDIN'
msg = ARGF.read msg = ARGF.read

View file

@ -12,7 +12,7 @@ class Channel::POP3 < Channel::EmailParser
port = 110 port = 110
end end
logger.info "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})" Rails.logger.info "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"
@pop = Net::POP3.new( channel[:options][:host], port ) @pop = Net::POP3.new( channel[:options][:host], port )
@ -27,11 +27,11 @@ class Channel::POP3 < Channel::EmailParser
end end
@pop.start( channel[:options][:user], channel[:options][:password] ) @pop.start( channel[:options][:user], channel[:options][:password] )
if check_type == 'check' if check_type == 'check'
logger.info 'check only mode, fetch no emails' Rails.logger.info 'check only mode, fetch no emails'
disconnect disconnect
return return
elsif check_type == 'verify' elsif check_type == 'verify'
logger.info 'verify mode, fetch no emails' Rails.logger.info 'verify mode, fetch no emails'
end end
mails = @pop.mails mails = @pop.mails
@ -45,13 +45,13 @@ class Channel::POP3 < Channel::EmailParser
mails.each do |m| mails.each do |m|
count += 1 count += 1
logger.info " - message #{count.to_s}/#{count_all.to_s}" Rails.logger.info " - message #{count.to_s}/#{count_all.to_s}"
# check for verify message # check for verify message
if check_type == 'verify' if check_type == 'verify'
mail = m.pop mail = m.pop
if mail && mail =~ /#{verify_string}/ if mail && mail =~ /#{verify_string}/
logger.info " - verify email #{verify_string} found" Rails.logger.info " - verify email #{verify_string} found"
m.delete m.delete
disconnect disconnect
return 'verify ok' return 'verify ok'
@ -66,9 +66,9 @@ class Channel::POP3 < Channel::EmailParser
end end
disconnect disconnect
if count == 0 if count == 0
logger.info ' - no message' Rails.logger.info ' - no message'
end end
logger.info 'done' Rails.logger.info 'done'
end end
def disconnect def disconnect

View file

@ -21,13 +21,13 @@ class Channel::TWITTER2
def fetch (channel) def fetch (channel)
logger.info "fetching tweets (oauth_token#{channel[:options][:oauth_token]})" Rails.logger.info "fetching tweets (oauth_token#{channel[:options][:oauth_token]})"
@client = connect(channel) @client = connect(channel)
# search results # search results
if channel[:options][:search] if channel[:options][:search]
channel[:options][:search].each { |search| channel[:options][:search].each { |search|
logger.info " - searching for #{search[:item]}" Rails.logger.info " - searching for #{search[:item]}"
tweets = [] tweets = []
@client.search( search[:item], count: 50, result_type: 'recent' ).collect do |tweet| @client.search( search[:item], count: 50, result_type: 'recent' ).collect do |tweet|
tweets.push tweet tweets.push tweet
@ -39,7 +39,7 @@ class Channel::TWITTER2
# mentions # mentions
if channel[:options][:mentions] if channel[:options][:mentions]
logger.info ' - searching for mentions' Rails.logger.info ' - searching for mentions'
tweets = @client.mentions_timeline tweets = @client.mentions_timeline
@article_type = 'twitter status' @article_type = 'twitter status'
fetch_loop( tweets, channel, channel[:options][:mentions][:group] ) fetch_loop( tweets, channel, channel[:options][:mentions][:group] )
@ -47,12 +47,12 @@ class Channel::TWITTER2
# direct messages # direct messages
if channel[:options][:direct_messages] if channel[:options][:direct_messages]
logger.info ' - searching for direct_messages' Rails.logger.info ' - searching for direct_messages'
tweets = @client.direct_messages tweets = @client.direct_messages
@article_type = 'twitter direct-message' @article_type = 'twitter direct-message'
fetch_loop( tweets, channel, channel[:options][:direct_messages][:group] ) fetch_loop( tweets, channel, channel[:options][:direct_messages][:group] )
end end
logger.info 'done' Rails.logger.info 'done'
disconnect disconnect
end end
@ -68,7 +68,7 @@ class Channel::TWITTER2
all_tweets.push tweet all_tweets.push tweet
end end
else else
logger.error 'UNKNOWN: ' + result_class.to_s Rails.logger.error 'UNKNOWN: ' + result_class.to_s
end end
# find tweets # find tweets
@ -86,7 +86,7 @@ class Channel::TWITTER2
# reset current_user # reset current_user
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
logger.info 'import tweet' Rails.logger.info 'import tweet'
fetch_import( tweet, channel, group ) fetch_import( tweet, channel, group )
end end
@ -113,7 +113,7 @@ class Channel::TWITTER2
begin begin
sender = @client.user(tweet.from_user_id) sender = @client.user(tweet.from_user_id)
rescue Exception => e rescue Exception => e
logger.error 'Exception: twitter: ' + e.inspect Rails.logger.error 'Exception: twitter: ' + e.inspect
return return
end end
end end
@ -121,16 +121,16 @@ class Channel::TWITTER2
# check if parent exists # check if parent exists
user = nil, ticket = nil, article = nil user = nil, ticket = nil, article = nil
if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != '' if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != ''
logger.info 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s Rails.logger.info 'import in_reply_tweet ' + tweet.in_reply_to_status_id.to_s
tweet_sub = @client.status( tweet.in_reply_to_status_id ) tweet_sub = @client.status( tweet.in_reply_to_status_id )
#logger.debug tweet_sub.inspect #Rails.logger.debug tweet_sub.inspect
(user, ticket, article) = fetch_import(tweet_sub, channel, group) (user, ticket, article) = fetch_import(tweet_sub, channel, group)
end end
# create stuff # create stuff
user = fetch_user_create(tweet, sender) user = fetch_user_create(tweet, sender)
if !ticket if !ticket
logger.info 'create new ticket...' Rails.logger.info 'create new ticket...'
ticket = fetch_ticket_create(user, tweet, sender, channel, group) ticket = fetch_ticket_create(user, tweet, sender, channel, group)
end end
article = fetch_article_create(user, ticket, tweet, sender) article = fetch_article_create(user, ticket, tweet, sender)
@ -144,11 +144,11 @@ class Channel::TWITTER2
auth = Authorization.where( uid: sender.id, provider: 'twitter' ).first auth = Authorization.where( uid: sender.id, provider: 'twitter' ).first
user = nil user = nil
if auth if auth
logger.info 'user_id', auth.user_id Rails.logger.info 'user_id', auth.user_id
user = User.where( id: auth.user_id ).first user = User.where( id: auth.user_id ).first
end end
if !user if !user
logger.info 'create user...' Rails.logger.info 'create user...'
roles = Role.where( name: 'Customer' ) roles = Role.where( name: 'Customer' )
user = User.create( user = User.create(
login: sender.screen_name, login: sender.screen_name,
@ -163,7 +163,7 @@ class Channel::TWITTER2
updated_by_id: 1, updated_by_id: 1,
created_by_id: 1 created_by_id: 1
) )
logger.info 'autentication create...' Rails.logger.info 'autentication create...'
authentication = Authorization.create( authentication = Authorization.create(
uid: sender.id, uid: sender.id,
username: sender.screen_name, username: sender.screen_name,
@ -171,7 +171,7 @@ class Channel::TWITTER2
provider: 'twitter' provider: 'twitter'
) )
else else
logger.info 'user exists'#, user.inspect Rails.logger.info 'user exists'#, user.inspect
end end
# set current user # set current user
@ -182,13 +182,13 @@ class Channel::TWITTER2
def fetch_ticket_create(user, tweet, sender, channel, group) def fetch_ticket_create(user, tweet, sender, channel, group)
#logger.info '+++++++++++++++++++++++++++' + tweet.inspect #Rails.logger.info '+++++++++++++++++++++++++++' + tweet.inspect
# check if ticket exists # check if ticket exists
if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != '' if tweet.respond_to?('in_reply_to_status_id') && tweet.in_reply_to_status_id && tweet.in_reply_to_status_id.to_s != ''
logger.info 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s Rails.logger.info 'tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
article = Ticket::Article.where( message_id: tweet.in_reply_to_status_id.to_s ).first article = Ticket::Article.where( message_id: tweet.in_reply_to_status_id.to_s ).first
if article if article
logger.info 'article with id found tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s Rails.logger.info 'article with id found tweet.in_reply_to_status_id found: ' + tweet.in_reply_to_status_id.to_s
return article.ticket return article.ticket
end end
end end
@ -269,7 +269,7 @@ class Channel::TWITTER2
end end
def send(attr, notification = false) def send(attr, notification = false)
# logger.debug('tweeeeettttt!!!!!!') # Rails.logger.debug('tweeeeettttt!!!!!!')
channel = Channel.where( area: 'Twitter::Inbound', active: true ).first channel = Channel.where( area: 'Twitter::Inbound', active: true ).first
client = Twitter::REST::Client.new do |config| client = Twitter::REST::Client.new do |config|
@ -279,13 +279,13 @@ class Channel::TWITTER2
config.access_token_secret = channel[:options][:oauth_token_secret] config.access_token_secret = channel[:options][:oauth_token_secret]
end end
if attr[:type] == 'twitter direct-message' if attr[:type] == 'twitter direct-message'
logger.info 'to:' + attr[:to].to_s Rails.logger.info 'to:' + attr[:to].to_s
dm = client.create_direct_message( dm = client.create_direct_message(
attr[:to].to_s, attr[:to].to_s,
attr[:body].to_s, attr[:body].to_s,
{} {}
) )
# logger.info dm.inspect # Rails.logger.info dm.inspect
return dm return dm
end end
@ -297,7 +297,7 @@ class Channel::TWITTER2
in_reply_to_status_id: attr[:in_reply_to] in_reply_to_status_id: attr[:in_reply_to]
} }
) )
# logger.debug message.inspect # Rails.logger.debug message.inspect
message message
end end
end end