Mercurial > trustbridge
annotate common/logging.c @ 622:c0f988e3df9f
Remove dummy messages and just forward the default messages
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 20 Jun 2014 09:56:10 +0200 |
parents | bc02ee484067 |
children | 5042ace08cba |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
252
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #include "logging.h" |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #include "strhelp.h" |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 #include <stdio.h> |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
12 #include <stdarg.h> |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
13 #include <stdbool.h> |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
14 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
15 #include <strhelp.h> |
252
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 #ifdef WIN32 |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
18 # include <windows.h> |
620
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
19 # include "events.h" |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
20 #else |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
21 # include <syslog.h> |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
22 #endif |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
23 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
24 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
25 #ifdef WIN32 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
26 static void |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
27 win_log(const char *format, va_list ap, bool error) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
28 { |
616
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
29 HANDLE log_src = NULL, |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
30 process_token = NULL; |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
31 wchar_t *wmsg = NULL; |
620
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
32 BOOL success = FALSE; |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
33 char buffer[MAX_LOG+1]; |
616
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
34 PTOKEN_USER user_struct = NULL; |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
35 PSID user_sid = NULL; |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
36 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
37 vsnprintf (buffer, MAX_LOG, format, ap); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
38 buffer[MAX_LOG] = '\0'; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
39 |
620
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
40 log_src = RegisterEventSourceW (NULL, L"" LOG_NAME); |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
41 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
42 if (log_src == NULL) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
43 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
44 PRINTLASTERROR ("Failed to open log source."); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
45 return; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
46 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
47 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
48 wmsg = utf8_to_wchar (buffer, strlen(buffer)); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
49 if (wmsg == NULL) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
50 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
51 ERRORPRINTF ("Failed to convert log message to utf-16"); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
52 goto done; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
53 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
54 |
616
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
55 /* Get the current user sid for logging */ |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
56 |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
57 OpenProcessToken (GetCurrentProcess(), TOKEN_READ, &process_token); |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
58 if (process_token) |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
59 { |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
60 DWORD size = 0; |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
61 |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
62 // check how much space is needed |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
63 GetTokenInformation (process_token, TokenUser, NULL, 0, &size); |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
64 if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
65 { |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
66 user_struct = xmalloc (size); |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
67 GetTokenInformation (process_token, TokenUser, user_struct, size, &size); |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
68 user_sid = user_struct->User.Sid; |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
69 } |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
70 } |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
71 |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
72 |
620
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
73 success = ReportEventW (log_src, |
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
74 error ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, |
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
75 EVENT_CAT_TB, |
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
76 error ? MSG_DEFAULT_ERROR : MSG_DEFAULT_INFO, |
616
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
77 user_sid, |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
78 1, |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
79 0, |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
80 (const WCHAR **) &wmsg, |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
81 NULL); |
620
bc02ee484067
Add dummy logging with ressourced messages.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
616
diff
changeset
|
82 if (!success) |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
83 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
84 PRINTLASTERROR ("Failed to report event."); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
85 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
86 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
87 done: |
616
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
88 if (process_token) |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
89 { |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
90 CloseHandle(process_token); |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
91 } |
0172740f5c6e
Include user information in windows event log messages
Andre Heinecke <andre.heinecke@intevation.de>
parents:
615
diff
changeset
|
92 xfree (user_struct); |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
93 xfree (wmsg); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
94 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
95 if (!DeregisterEventSource (log_src)) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
96 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
97 PRINTLASTERROR ("Failed to close log source."); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
98 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
99 return; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
100 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
101 |
252
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
102 char * |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
103 getLastErrorMsg() |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
104 { |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
105 LPWSTR bufPtr = NULL; |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
106 DWORD err = GetLastError(); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
107 char *retval = NULL; |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
108 FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
109 FORMAT_MESSAGE_FROM_SYSTEM | |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
110 FORMAT_MESSAGE_IGNORE_INSERTS, |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
111 NULL, err, 0, (LPWSTR) &bufPtr, 0, NULL); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
112 if (!bufPtr) |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
113 { |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
114 HMODULE hWinhttp = GetModuleHandleW (L"crypt32"); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
115 if (hWinhttp) |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
116 { |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
117 FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
118 FORMAT_MESSAGE_FROM_HMODULE | |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
119 FORMAT_MESSAGE_IGNORE_INSERTS, |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 hWinhttp, HRESULT_CODE (err), 0, |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 (LPWSTR) &bufPtr, 0, NULL); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 } |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 } |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
124 if (!bufPtr) { |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
125 fprintf (stderr, "Error getting last error for code: %lx \n", err); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
126 return NULL; |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
127 } |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
128 |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
129 retval = wchar_to_utf8(bufPtr, wcslen(bufPtr)); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
130 LocalFree (bufPtr); |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
131 |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
132 return retval; |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
133 } |
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
134 |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
135 #else /* WIN32 */ |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
136 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
137 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
138 static void |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
139 linux_log (const char *format, va_list ap, bool error) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
140 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
141 openlog (LOG_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
142 vsyslog ( error ? LOG_ERR : LOG_INFO, format, ap); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
143 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
144 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
145 #endif /* WIN32 */ |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
146 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
147 void |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
148 syslog_info_printf(const char *format, ...) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
149 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
150 va_list args; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
151 va_start (args, format); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
152 #ifdef WIN32 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
153 win_log (format, args, false); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
154 #else |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
155 linux_log (format, args, false); |
252
bd7fb50078b4
Add logging.h for some logging / debug functions
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
156 #endif |
615
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
157 va_end (args); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
158 } |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
159 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
160 void |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
161 syslog_error_printf(const char *format, ...) |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
162 { |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
163 va_list args; |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
164 va_start (args, format); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
165 #ifdef WIN32 |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
166 win_log (format, args, true); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
167 #else |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
168 linux_log (format, args, true); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
169 #endif |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
170 va_end (args); |
2a4f7364ab81
Add first simple event logging functions
Andre Heinecke <andre.heinecke@intevation.de>
parents:
404
diff
changeset
|
171 } |