Samples

The following programs and examples illustrate all that is needed to start logging. Also feel free to visit the web site for additional ideas and samples as Diamond Sierra is constantly adding support for new applications and environments. Current API extensions (available only through the web site) include SQL Server, Sybase, InstallShield, and more.

Using the C API

#include <PB.h>

VOID main(INT argc, CHAR* argv[])
{
PB_COMPONENT    cp = {L"My component", L"", TRUE, 0};
PB_CONTEXT    cx = {L"My context", TRUE, 0};

PBSetDefaultComponent(&cp, PB_MODULE_DEFAULT);    /* Set default 'component'.*/
PBSetDefaultContext(&cx, PB_THREAD_DEFAULT);        /* Set default 'context'.  */

/*
* Log a message using the default component and context set above.
* Note that PBLog() supports printf() formatting.
*/
PBLog(NULL, NULL, PB_WARNING, "This program (%s) does nothing.", argv[0]);
}

Using the C++ API

#include <PB.h>

VOID main(INT argc, CHAR* argv[])
{
CPBScopeLogger    slgr(PB_STATUS, "main()");    //Log entrance/exit of scope 'main()'.
CPBComponent    cp("My component");    //Set default 'component'.
CPBContext    cx("Some context");    //Set default 'context'.
CPBLogger    lgr;

//
// Log a message using the default component and context set above.
// Note that PBLog() supports printf () formatting.
//
lgr.Log(PB_WARNING, "This program (%s) does nothing.", argv[0]);
}

Using the COM interface from Visual Basic

(Note: Paul Bunyan’s type library must be registered with the Visual Basic IDE before it can be used.)

Private Sub Ok_Click()
'Declare logger object
Dim lgr As New PBLogger

'Log a message
lgr.Log "WARNING", "Some warning..."
End Sub

Using the command line interface

Remarks