Monday, June 21, 2010

Simple Lotusscript Logger

This is in analogous to the post found in the following location :

http://ozinisle.blogspot.com/2010/05/xpage-error-handler.html

You may have to create the small database that is mentioned in that post (... will hardly take a minute)

The following is its lotus script equivalent,

Public Class LSLog
    Private session As NotesSession
    Private logDB As NotesDatabase
    Private logDoc As NotesDocument
    Private instantUpdate As Boolean
    Private logHistory As String
    Private isDebug As Boolean
   
    Public Sub new
        isDebug=False
        If Not isDebug Then Exit Sub
        Set session = New NotesSession
        Set logDB=session.GetDatabase("","myXPageLog.nsf")
        Set logDoc=logDB.CreateDocument
        logDoc.Form="log"
        instantUpdate=True
    End Sub
   
    Public Function update (detail As String)
        If Not isDebug Then Exit Function
        logHistory=logHistory & detail & Chr(13)
        If instantUpdate Then
            Call logDoc.ReplaceItemValue("log",logHistory)
            Call logDoc.Save(True,False)
        End If
    End Function
   
    Public Function close
        If Not isDebug Then Exit Function
        Call logDoc.ReplaceItemValue("log",logHistory)
        Call logDoc.Save(True,False)
    End Function
   
    Public Function kickInsert(anyValue As Variant)
        If Not isDebug Then Exit Function
        Call logDoc.ReplaceItemValue("log",anyValue)
        Call logDoc.Save(True,False)   
    End Function
   
End Class

No comments:

Post a Comment