@@ -43,7 +43,7 @@ public EmailMonitoringService(
4343 protected override async Task ExecuteAsync ( CancellationToken stoppingToken )
4444 {
4545 _serviceCancellationToken = stoppingToken ;
46- _logger . LogInformation ( "📧 Email monitoring service starting... " ) ;
46+ _logger . LogInformation ( "Email monitoring service starting" ) ;
4747
4848 while ( ! stoppingToken . IsCancellationRequested )
4949 {
@@ -53,7 +53,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
5353 }
5454 catch ( OperationCanceledException )
5555 {
56- _logger . LogInformation ( "📧 Email monitoring service is stopping... " ) ;
56+ _logger . LogInformation ( "Email monitoring service is stopping" ) ;
5757 break ;
5858 }
5959 catch ( Exception ex )
@@ -76,15 +76,15 @@ private async Task ConnectAndMonitorAsync(CancellationToken cancellationToken)
7676 var inbox = _client . Inbox ;
7777 await inbox . OpenAsync ( FolderAccess . ReadOnly , cancellationToken ) ;
7878
79- _logger . LogInformation ( "✅ Connected successfully. Processing existing emails... " ) ;
79+ _logger . LogInformation ( "Connected to mail server " ) ;
8080 await ProcessMails ( false , cancellationToken ) ;
8181 _lastFullReprocess = DateTime . UtcNow ; // Track when we last did a full reprocess
8282
8383 // Subscribe to events
8484 inbox . CountChanged += OnCountChanged ;
8585 inbox . MessageExpunged += OnMessageExpunged ;
8686
87- _logger . LogInformation ( "👀 Now monitoring for new emails... ") ;
87+ _logger . LogDebug ( " Now monitoring for new emails") ;
8888 await MonitorForNewEmailsAsync ( cancellationToken ) ;
8989 }
9090 finally
@@ -101,7 +101,7 @@ private async Task ConnectAndMonitorAsync(CancellationToken cancellationToken)
101101
102102 private async Task ConnectToServerAsync ( ImapClient client , CancellationToken cancellationToken )
103103 {
104- _logger . LogInformation ( "🔌 Connecting to IMAP server {Server}:{Port}... ", _config . Server , _config . Port ) ;
104+ _logger . LogDebug ( " Connecting to IMAP server {Server}:{Port}", _config . Server , _config . Port ) ;
105105
106106 await client . ConnectAsync ( _config . Server , _config . Port , SecureSocketOptions . SslOnConnect , cancellationToken ) ;
107107 await client . AuthenticateAsync ( _config . Username , _config . Password , cancellationToken ) ;
@@ -113,7 +113,7 @@ private async Task ProcessMails(bool lastSeenOnly, CancellationToken cancellatio
113113 return ;
114114
115115 var totalEmails = _client . Inbox . Count ;
116- _logger . LogInformation ( "📬 Processing {TotalEmails} existing emails... ", totalEmails ) ;
116+ _logger . LogDebug ( " Processing {TotalEmails} existing emails", totalEmails ) ;
117117
118118
119119 IList < IMessageSummary > ? fetchedMessages = null ;
@@ -130,7 +130,7 @@ private async Task ProcessMails(bool lastSeenOnly, CancellationToken cancellatio
130130 }
131131 if ( fetchedMessages == null || fetchedMessages . Count == 0 )
132132 {
133- _logger . LogInformation ( "No emails to process in the inbox. " ) ;
133+ _logger . LogDebug ( "No emails to process in the inbox" ) ;
134134 return ;
135135 }
136136 for ( int i = 0 ; i < fetchedMessages . Count ; i ++ )
@@ -150,7 +150,7 @@ private async Task ProcessMails(bool lastSeenOnly, CancellationToken cancellatio
150150 }
151151
152152 _lastProcessedCount = totalEmails ;
153- _logger . LogInformation ( "✅ Finished processing {TotalEmails} existing emails", totalEmails ) ;
153+ _logger . LogDebug ( " Finished processing {TotalEmails} existing emails", totalEmails ) ;
154154 var triggers = await this . ProcessBatchAsync ( emailsToProcess ) ;
155155
156156 // Run inbox cleanup after rule processing
@@ -174,7 +174,7 @@ private async Task<List<RuleTrigger>> ProcessBatchAsync(List<EmailReceivedEventA
174174
175175 var stopwatch = System . Diagnostics . Stopwatch . StartNew ( ) ;
176176
177- _logger . LogInformation ( "🔄 Starting batch processing of {EmailCount} emails... ", emailsToProcess . Count ) ;
177+ _logger . LogDebug ( " Starting batch processing of {EmailCount} emails", emailsToProcess . Count ) ;
178178
179179 // Process emails in batch
180180 var triggers = _batchRuleProcessor . ProcessEmailBatch ( emailsToProcess ) ;
@@ -191,7 +191,7 @@ private async Task<List<RuleTrigger>> ProcessBatchAsync(List<EmailReceivedEventA
191191 }
192192
193193 var ops = _emailMover . ExecuteTriggers ( triggers ) ;
194- _logger . LogInformation ( "📦 Executed {OperationCount} move operations and {FlagCount} flag operations",
194+ _logger . LogDebug ( " Executed {OperationCount} move operations and {FlagCount} flag operations",
195195 ops . Count , flagOps . Count ) ;
196196 foreach ( var op in ops )
197197 {
@@ -209,7 +209,7 @@ private async Task<List<RuleTrigger>> ProcessBatchAsync(List<EmailReceivedEventA
209209 EmailsMoved = emailsMoved ,
210210 ProcessingTime = stopwatch . Elapsed
211211 } ;
212- _logger . LogInformation ( "🔄 Batch completed: {EmailsProcessed} emails, {RulesMatched} matches , {EmailsMoved} moved in {ProcessingTime}ms" ,
212+ _logger . LogInformation ( "Processed {EmailsProcessed} emails, {RulesMatched} matched , {EmailsMoved} moved in {ProcessingTime}ms" ,
213213 batchEventArgs . EmailsProcessed , batchEventArgs . RulesMatched , batchEventArgs . EmailsMoved , batchEventArgs . ProcessingTime . TotalMilliseconds ) ;
214214
215215 return triggers ;
@@ -250,7 +250,7 @@ private async Task ProcessSingleEmail(IMessageSummary message, IMailFolder folde
250250 } ;
251251 if ( emailArgs . IsImportant )
252252 {
253- _logger . LogInformation ( "⭐ Important email detected (skipping rules): {Subject} from {Sender} at {Date}",
253+ _logger . LogDebug ( " Important email detected (skipping rules): {Subject} from {Sender} at {Date}",
254254 emailArgs . Subject , emailArgs . SenderName , emailArgs . ReceivedDate ) ;
255255 }
256256 processList . Add ( emailArgs ) ;
@@ -275,7 +275,7 @@ private void ProcessInboxCleanup(List<EmailReceivedEventArgs> emails, HashSet<Un
275275 var important = candidates . Where ( e => e . IsImportant ) . ToList ( ) ;
276276 var nonImportant = candidates . Where ( e => ! e . IsImportant ) . ToList ( ) ;
277277
278- _logger . LogInformation ( "🧹 Inbox cleanup: {ImportantCount} important → {ImportantFolder}, {NonImportantCount} non-important → Trash" ,
278+ _logger . LogInformation ( "Inbox cleanup: {ImportantCount} important -> {ImportantFolder}, {NonImportantCount} non-important -> Trash" ,
279279 important . Count , _config . ImportantFolder , nonImportant . Count ) ;
280280
281281 if ( important . Any ( ) )
@@ -293,7 +293,8 @@ private void ProcessInboxCleanup(List<EmailReceivedEventArgs> emails, HashSet<Un
293293 SenderEmailaddress = e . SenderAddress ,
294294 Date = e . ReceivedDate ,
295295 Folder = "INBOX" ,
296- MoveTo = _config . ImportantFolder
296+ MoveTo = _config . ImportantFolder ,
297+ Rule = "Inbox cleanup"
297298 } ) . ToList ( )
298299 } ) ;
299300 }
@@ -313,7 +314,8 @@ private void ProcessInboxCleanup(List<EmailReceivedEventArgs> emails, HashSet<Un
313314 SenderEmailaddress = e . SenderAddress ,
314315 Date = e . ReceivedDate ,
315316 Folder = "INBOX" ,
316- MoveTo = "Trash"
317+ MoveTo = "Trash" ,
318+ Rule = "Inbox cleanup"
317319 } ) . ToList ( )
318320 } ) ;
319321 }
@@ -329,7 +331,7 @@ private async Task MonitorForNewEmailsAsync(CancellationToken stoppingToken)
329331 var timeSinceLastReprocess = DateTime . UtcNow - _lastFullReprocess ;
330332 if ( timeSinceLastReprocess . TotalMilliseconds >= HourlyReprocessIntervalMs )
331333 {
332- _logger . LogInformation ( "⏰ Hourly reprocessing time reached. Exiting IDLE to reprocess all emails... ") ;
334+ _logger . LogDebug ( "Reprocess interval reached. Exiting IDLE to reprocess all emails") ;
333335 await ProcessMails ( false , stoppingToken ) ;
334336 _lastFullReprocess = DateTime . UtcNow ;
335337 continue ; // Skip the IDLE cycle and immediately check again
@@ -373,10 +375,10 @@ private async Task MonitorForNewEmailsAsync(CancellationToken stoppingToken)
373375
374376 try
375377 {
376- // Enter IDLE mode – will block until done token is canceled or timeout
378+ // Enter IDLE mode - will block until done token is canceled or timeout
377379 if ( _client . Capabilities . HasFlag ( ImapCapabilities . Idle ) )
378380 {
379- _logger . LogDebug ( "📱 Entering IDLE mode for {Timeout} (next full reprocess in {NextReprocess})" ,
381+ _logger . LogDebug ( "Entering IDLE mode for {Timeout} (next full reprocess in {NextReprocess})" ,
380382 actualTimeout , remainingTime ) ;
381383 await _client . IdleAsync ( idleDone . Token , stoppingToken ) ;
382384 }
@@ -391,7 +393,7 @@ private async Task MonitorForNewEmailsAsync(CancellationToken stoppingToken)
391393 {
392394 if ( stoppingToken . IsCancellationRequested )
393395 {
394- _logger . LogInformation ( "📧 Monitoring stopped due to service shutdown") ;
396+ _logger . LogDebug ( " Monitoring stopped due to service shutdown") ;
395397 break ;
396398 }
397399 // Expected when _idleDoneSource is triggered by event handlers, move queue, or timeout
@@ -473,7 +475,7 @@ private async Task ProcessQueuedMoveOperationsAsync()
473475 if ( processedCount > 0 )
474476 {
475477 stopwatch . Stop ( ) ;
476- _logger . LogInformation ( "✅ Processed {Count} move operations in {ElapsedMs}ms",
478+ _logger . LogDebug ( " Processed {Count} move operations in {ElapsedMs}ms",
477479 processedCount , stopwatch . ElapsedMilliseconds ) ;
478480 }
479481 }
@@ -507,7 +509,7 @@ private async Task ProcessQueuedFlagOperationsAsync()
507509
508510 if ( processedCount > 0 )
509511 {
510- _logger . LogInformation ( "⭐ Processed {Count} flag operations", processedCount ) ;
512+ _logger . LogDebug ( " Processed {Count} flag operations", processedCount ) ;
511513 }
512514 }
513515
@@ -523,7 +525,7 @@ private async Task ProcessSingleFlagOperationAsync(EmailFlagOperation flagOperat
523525 await folder . OpenAsync ( FolderAccess . ReadWrite ) ;
524526 await folder . AddFlagsAsync ( flagOperation . EmailIds , MessageFlags . Flagged , true ) ;
525527
526- _logger . LogInformation ( "⭐ Flagged {Count} emails as important in {Folder}" ,
528+ _logger . LogInformation ( "Flagged {Count} emails as important in {Folder}" ,
527529 flagOperation . EmailIds . Count , flagOperation . SourceFolder ) ;
528530 }
529531 catch ( Exception ex )
@@ -558,7 +560,13 @@ private async Task ProcessSingleMoveOperationAsync(EmailMoveOperation moveOperat
558560 // Perform the move
559561 await sourceFolder . MoveToAsync ( moveOperation . EmailIds , destinationFolder ) ;
560562
561- _logger . LogInformation ( "📁 Moved {Count} emails from {Source} to {Destination}" ,
563+ foreach ( var email in moveOperation . Emails )
564+ {
565+ _logger . LogInformation ( "Moved email: from='{From}' subject='{Subject}' to='{Destination}' rule='{Rule}'" ,
566+ email . SenderEmailaddress , email . Subject , moveOperation . DestinationFolder , email . Rule ?? "unknown" ) ;
567+ }
568+
569+ _logger . LogDebug ( "Moved {Count} emails from {Source} to {Destination}" ,
562570 moveOperation . Emails . Count , moveOperation . SourceFolder , moveOperation . DestinationFolder ) ;
563571 }
564572 catch ( Exception ex )
@@ -593,7 +601,7 @@ private void OnCountChanged(object? sender, EventArgs e)
593601 var folder = ( IMailFolder ) sender ! ;
594602 if ( folder . Count > _lastProcessedCount )
595603 {
596- _logger . LogDebug ( "[Event] Inbox count increased to {CurrentCount} (was {LastCount}) – new message likely." ,
604+ _logger . LogDebug ( "[Event] Inbox count increased to {CurrentCount} (was {LastCount}) - new message likely." ,
597605 folder . Count , _lastProcessedCount ) ;
598606 _newMessagesFlag = true ;
599607 var source = _idleDoneSource ;
@@ -625,7 +633,7 @@ private async Task DisconnectAsync(ImapClient? client, CancellationToken cancell
625633
626634 public override async Task StopAsync ( CancellationToken cancellationToken )
627635 {
628- _logger . LogInformation ( "📧 Email monitoring service is stopping... " ) ;
636+ _logger . LogInformation ( "Email monitoring service is stopping" ) ;
629637
630638 // Cancel any ongoing IDLE operation
631639 var source = _idleDoneSource ;
0 commit comments