source: vendor/synergy/current/lib/arch/CArchLogWindows.cpp

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 1.9 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include "CArchLogWindows.h"
16#include "CArchMiscWindows.h"
17#include <string.h>
18
19//
20// CArchLogWindows
21//
22
23CArchLogWindows::CArchLogWindows() : m_eventLog(NULL)
24{
25 // do nothing
26}
27
28CArchLogWindows::~CArchLogWindows()
29{
30 // do nothing
31}
32
33void
34CArchLogWindows::openLog(const char* name)
35{
36 if (m_eventLog == NULL && !CArchMiscWindows::isWindows95Family()) {
37 m_eventLog = RegisterEventSource(NULL, name);
38 }
39}
40
41void
42CArchLogWindows::closeLog()
43{
44 if (m_eventLog != NULL) {
45 DeregisterEventSource(m_eventLog);
46 m_eventLog = NULL;
47 }
48}
49
50void
51CArchLogWindows::showLog(bool)
52{
53 // do nothing
54}
55
56void
57CArchLogWindows::writeLog(ELevel level, const char* msg)
58{
59 if (m_eventLog != NULL) {
60 // convert priority
61 WORD type;
62 switch (level) {
63 case kERROR:
64 type = EVENTLOG_ERROR_TYPE;
65 break;
66
67 case kWARNING:
68 type = EVENTLOG_WARNING_TYPE;
69 break;
70
71 default:
72 type = EVENTLOG_INFORMATION_TYPE;
73 break;
74 }
75
76 // log it
77 // FIXME -- win32 wants to use a message table to look up event
78 // strings. log messages aren't organized that way so we'll
79 // just dump our string into the raw data section of the event
80 // so users can at least see the message. note that we use our
81 // level as the event category.
82 ReportEvent(m_eventLog, type, static_cast<WORD>(level),
83 0, // event ID
84 NULL,
85 0,
86 strlen(msg) + 1, // raw data size
87 NULL,
88 const_cast<char*>(msg));// raw data
89 }
90}
Note: See TracBrowser for help on using the repository browser.