Patch #7177

Make POP3 mail fetcher log messages instead of puts

Added by Vitaly Martynenko almost 7 years ago. Updated almost 7 years ago.

Status:ClosedStart date:2010-12-27
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Email receiving
Target version:-

Related issues

Related to Redmine - Defect #7367: Receiving pop3 email should not output debug messages Closed 2011-01-19

Associated revisions

Revision 4737
Added by Jean-Philippe Lang almost 7 years ago

Make POP3 mail fetcher log messages instead of puts (#7177).

History

#1 Updated by Vitaly Martynenko almost 7 years ago

Index: trunk/lib/redmine/pop3.rb
===================================================================
--- trunk/lib/redmine/pop3.rb   (revision 4574)
+++ trunk/lib/redmine/pop3.rb   (working copy)
@@ -27,30 +27,36 @@
         delete_unprocessed = (pop_options[:delete_unprocessed].to_s == '1')

         pop = Net::POP3.APOP(apop).new(host,port)
-        puts "Connecting to #{host}..." 
+        logger.debug "Connecting to #{host}..." if logger && logger.debug?
         pop.start(pop_options[:username], pop_options[:password]) do |pop_session|
           if pop_session.mails.empty?
-            puts "No email to process" 
+            logger.debug "No email to process" if logger && logger.debug?
           else
-            puts "#{pop_session.mails.size} email(s) to process..." 
+            logger.debug "#{pop_session.mails.size} email(s) to process..." if logger && logger.debug?
             pop_session.each_mail do |msg|
               message = msg.pop
               message_id = (message =~ /^Message-ID: (.*)/ ? $1 : '').strip
               if MailHandler.receive(message, options)
                 msg.delete
-                puts "--> Message #{message_id} processed and deleted from the server" 
+                logger.debug "--> Message #{message_id} processed and deleted from the server" if logger && logger.debug?
               else
                 if delete_unprocessed
                   msg.delete
-                  puts "--> Message #{message_id} NOT processed and deleted from the server" 
+                  logger.debug "--> Message #{message_id} NOT processed and deleted from the server" if logger && logger.debug?
                 else
-                  puts "--> Message #{message_id} NOT processed and left on the server" 
+                  logger.debug "--> Message #{message_id} NOT processed and left on the server" if logger && logger.debug?
                 end
               end
             end
           end
         end
       end
+
+      private
+
+      def logger
+        RAILS_DEFAULT_LOGGER
+      end
     end
   end
 end

#2 Updated by Jean-Philippe Lang almost 7 years ago

  • Status changed from New to Closed

Patch committed in r4737, thanks.

Also available in: Atom PDF