71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
|
|
|
namespace Kreta.Framework.Logging
|
|
{
|
|
/// <summary>
|
|
/// A naplóvezetők absztrakt ősosztálya.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az ősosztály felelőssége a naplózás során történt kivételek egységes kezelése, így azzal a
|
|
/// leszármazott osztályoknak nem kell foglalkozniuk.
|
|
/// </remarks>
|
|
public abstract class LogWriterBase : ILogWriter
|
|
{
|
|
/// <summary>
|
|
/// Fizikailag a naplóba ír egy üzenetet.
|
|
/// </summary>
|
|
/// <param name="message">A naplóba vezetendő üzenet</param>
|
|
protected abstract Guid? DoLog(ILogMessage message);
|
|
|
|
/// <summary>
|
|
/// Does the log.
|
|
/// </summary>
|
|
/// <param name="message">The message.</param>
|
|
/// <param name="logId">The log identifier.</param>
|
|
/// <returns></returns>
|
|
protected abstract void DoLog(ILogMessage message, Guid logId);
|
|
|
|
/// <summary>
|
|
/// Naplóba ír egy naplóbejegyzést.
|
|
/// </summary>
|
|
/// <param name="message">A naplóbejegyzés</param>
|
|
public Guid? Log(ILogMessage message)
|
|
{
|
|
try
|
|
{
|
|
return DoLog(message);
|
|
}
|
|
catch (LogWriterException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw new LogWriterException(message, string.Format("Failure writing log in class {0}.", GetType().FullName), exception);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Logs the specified message.
|
|
/// </summary>
|
|
/// <param name="message">The message.</param>
|
|
/// <param name="logId">The log identifier.</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="LogWriterException"></exception>
|
|
public void Log(ILogMessage message, Guid logId)
|
|
{
|
|
try
|
|
{
|
|
DoLog(message, logId);
|
|
}
|
|
catch (LogWriterException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw new LogWriterException(message, string.Format("Failure writing log in class {0}.", GetType().FullName), exception);
|
|
}
|
|
}
|
|
}
|
|
}
|