Imports Quartz.Logging

Public Class LogProvider
    Implements ILogProvider

    Private ReadOnly Logger As DigitalData.Modules.Logging.Logger

    Public Sub New(Logger As DigitalData.Modules.Logging.Logger)
        MyBase.New()
        Me.Logger = Logger
    End Sub

    Public Function OpenNestedContext(message As String) As IDisposable Implements ILogProvider.OpenNestedContext
        Throw New NotImplementedException()
    End Function

    Public Function OpenMappedContext(key As String, value As Object, Optional destructure As Boolean = False) As IDisposable Implements ILogProvider.OpenMappedContext
        Throw New NotImplementedException()
    End Function

    Private Function GetLogger(name As String) As Logger Implements ILogProvider.GetLogger
        Return Function(level, func, exception, parameters)
                   If exception IsNot Nothing Then
                       Logger.Error(exception)
                   ElseIf level >= LogLevel.Debug AndAlso func IsNot Nothing Then
                       Logger.Debug(func(), parameters)
                   ElseIf level >= LogLevel.Info AndAlso func IsNot Nothing Then
                       Logger.Info(func(), parameters)
                   End If

                   Return True
               End Function
    End Function
End Class
