116 lines
2.7 KiB
OpenEdge ABL
116 lines
2.7 KiB
OpenEdge ABL
VERSION 1.0 CLASS
|
|
BEGIN
|
|
MultiUse = -1 'True
|
|
Persistable = 0 'NotPersistable
|
|
DataBindingBehavior = 0 'vbNone
|
|
DataSourceBehavior = 0 'vbNone
|
|
MTSTransactionMode = 0 'NotAnMTSObject
|
|
END
|
|
Attribute VB_Name = "CLogger"
|
|
Attribute VB_GlobalNameSpace = False
|
|
Attribute VB_Creatable = True
|
|
Attribute VB_PredeclaredId = False
|
|
Attribute VB_Exposed = False
|
|
'==============================================================================
|
|
'
|
|
' File : Logger.cls
|
|
' Date : 22.02.1999
|
|
' Version: 1.00
|
|
' Author : Andreas Schmidt, lindner&partner
|
|
'
|
|
'==============================================================================
|
|
'
|
|
' *shared*
|
|
'
|
|
' Hilfsklasse zum protokollieren von Fehlern, Warnungen und Hinweisen.
|
|
'
|
|
' @see ILogConsumer
|
|
'
|
|
'==============================================================================
|
|
'
|
|
' History:
|
|
'
|
|
' Date : 22.02.1999
|
|
' Version: 1.00
|
|
' Author : Andreas Schmidt, lindner&partner
|
|
'
|
|
' Erste dokumentierte Version.
|
|
'
|
|
'==============================================================================
|
|
|
|
Option Explicit
|
|
|
|
' Private Member
|
|
' --------------
|
|
Private m_nMaxLevel As Integer
|
|
Private m_consumers As Collection
|
|
|
|
|
|
Private Sub Class_Initialize()
|
|
Set m_consumers = New Collection
|
|
m_nMaxLevel = 99
|
|
End Sub
|
|
|
|
Private Sub Class_Terminate()
|
|
Dim consumer As ILogConsumer
|
|
For Each consumer In m_consumers
|
|
Call consumer.logClose
|
|
Next
|
|
End Sub
|
|
|
|
' @param nLevel Vorgabe des maximalen Loglevels
|
|
'
|
|
Public Sub setMaxLevel(nLevel As Integer)
|
|
m_nMaxLevel = nLevel
|
|
End Sub
|
|
|
|
Public Sub addConsumer(ilc As ILogConsumer)
|
|
Call m_consumers.Add(ilc)
|
|
Call ilc.logStart
|
|
End Sub
|
|
|
|
' @param nLevel Log-Level
|
|
' 1 = Error
|
|
' 2 = Warning
|
|
' 3 = Info
|
|
' n = weitere Infos
|
|
' @param sText Zu loggender Text
|
|
'
|
|
Public Sub log(nLevel As Integer, ByVal sText As String)
|
|
Debug.Print sText
|
|
Dim consumer As ILogConsumer
|
|
|
|
sText = Trim$(sText)
|
|
If (nLevel > m_nMaxLevel) Or sText = "" Then Exit Sub
|
|
|
|
' CRs und LFs ausfiltern
|
|
' ----------------------
|
|
Dim i As Integer
|
|
Do While InStr(1, sText, Chr$(13)) > 0
|
|
i = InStr(1, sText, Chr$(13))
|
|
sText = RTrim(Left$(sText, i - 1)) + " " + Mid$(sText, i + 1)
|
|
Loop
|
|
|
|
Do While InStr(1, sText, Chr$(10)) > 0
|
|
i = InStr(1, sText, Chr$(10))
|
|
sText = Left$(sText, i - 1) + Mid$(sText, i + 1)
|
|
Loop
|
|
|
|
For Each consumer In m_consumers
|
|
Call consumer.log(nLevel, getDate() + " " + GetTime() + ": " + sText)
|
|
Next
|
|
End Sub
|
|
|
|
' @return aktuelle Uhrzeit als String
|
|
'
|
|
Private Function GetTime() As String
|
|
GetTime = Format$(Time, "hh:mm:ss")
|
|
End Function
|
|
|
|
' @return aktuelles Datum als String
|
|
'
|
|
Private Function getDate() As String
|
|
getDate = Format$(Date, "dd.mm.yyyy")
|
|
End Function
|
|
|