<commit_before>using System;
using System.Diagnostics;
using System.Text;

namespace HelloSvc.Logging
{
	public class EventLogLogger : ILogger
	{
		protected virtual EventLog Log
		{
			get;
			private set;
		}
		
		public EventLogLogger(EventLog log)
		{
			Log = log.ThrowIfNull("log");
		}
		
		public void Message(string message)
		{
			Log.WriteEntry(message);
		}

		public void ExceptionWithMessage(Exception ex, string message)
		{
			var formatter = new StringBuilder(message);
			formatter.AppendLine();
			formatter.AppendLine(ex.ToString());
			
			Log.WriteEntry(formatter.ToString());
		}

		public void ExceptionAlone(Exception ex)
		{
			Log.WriteEntry(ex.ToString());
		}
	}
}
<commit_msg>Added try/catch to prevent logging errors from crashing service.<commit_after>using System;
using System.Diagnostics;
using System.Text;

namespace HelloSvc.Logging
{
	public class EventLogLogger : ILogger
	{
		protected virtual EventLog Log
		{
			get;
			private set;
		}
		
		public EventLogLogger(EventLog log)
		{
			Log = log.ThrowIfNull("log");
		}
		
		public void Message(string message)
		{
			try
			{
				Log.WriteEntry(message);
			}
			catch
			{
				// Suppress. Nothing can be done except to not let logging crash the service.
			}
		}

		public void ExceptionWithMessage(Exception ex, string message)
		{
			try
			{
				var formatter = new StringBuilder(message);
				formatter.AppendLine();
				formatter.AppendLine(ex.ToString());
				
				Log.WriteEntry(formatter.ToString());
			}
			catch
			{
				// Suppress. Nothing can be done except to not let logging crash the service.
			}
		}

		public void ExceptionAlone(Exception ex)
		{
			try
			{
				Log.WriteEntry(ex.ToString());
			}
			catch
			{
				// Suppress. Nothing can be done except to not let logging crash the service.
			}
		}
	}
}

{'fraction_non_alphanumeric': 0.09649122807017543, 'fraction_numerical': 0.0, 'mean_word_length': 3.0198237885462555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3302306', 'n_tokens_mistral': 703, 'n_tokens_neox': 559, 'n_words': 147}