summaryrefslogtreecommitdiffstats
path: root/lib/base/eventlog.cpp
blob: b3d3c19f3c14637b6fd1a8e214857e45876e0368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/** BEGIN COPYRIGHT BLOCK
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
//                                                                          //
//  Name: EVENTLOG                                                          //
//	Platforms: WIN32                                                        //
//  ......................................................................  //
//  Revision History:                                                       //
//  01-12-95  Initial Version, Aruna Victor (aruna@netscape.com)            //
//  12-02-96  Code cleanup, Andy Hakim (ahakim@netscape.com)                //
//            - consolidated admin and http functions into one              //
//            - moved registry modification code to installer               //
//            - removed several unecessary functions                        //
//            - changed function parameters to existing functions           //
//                                                                          //
//--------------------------------------------------------------------------//

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "netsite.h"
#include "base/eventlog.h"
#include <nt/regparms.h>
#include <nt/messages.h>

HANDLE ghEventSource;

NSPR_BEGIN_EXTERN_C

NSAPI_PUBLIC HANDLE InitializeLogging(char *szEventLogName)
{
    ghEventSource = RegisterEventSource(NULL, szEventLogName);
    return ghEventSource;
}



NSAPI_PUBLIC BOOL TerminateLogging(HANDLE hEventSource)
{
    BOOL bReturn = FALSE;
    if(hEventSource == NULL)
        hEventSource = ghEventSource;
    if(hEventSource)
        bReturn = DeregisterEventSource(hEventSource);
    return(bReturn);
}



NSAPI_PUBLIC BOOL LogErrorEvent(HANDLE hEventSource, WORD fwEventType, WORD fwCategory, DWORD IDEvent, LPTSTR chMsg, LPTSTR lpszMsg)
{
    BOOL bReturn = FALSE;
    LPTSTR lpszStrings[2];

	lpszStrings[0] = chMsg;
    lpszStrings[1] = lpszMsg;

    if(hEventSource == NULL)
        hEventSource = ghEventSource;

    if(hEventSource)
        bReturn = ReportEvent(hEventSource, fwEventType, fwCategory,
                        IDEvent, NULL, 2, 0, (LPCTSTR *)lpszStrings, NULL);
    return(bReturn);
}

NSPR_END_EXTERN_C