diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-21 21:26:26 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-21 21:26:26 +0100 |
commit | aadee5804b8e10a0ce1a0cd92e5f50a4459a01dc (patch) | |
tree | a99a3aed3f532ae967ed0cc78662e419f6cc7c77 /src/log | |
parent | 2a5fa35d23049b03273faaf13c3c2b86457ee6ba (diff) | |
download | wolfbones-aadee5804b8e10a0ce1a0cd92e5f50a4459a01dc.tar.gz wolfbones-aadee5804b8e10a0ce1a0cd92e5f50a4459a01dc.tar.bz2 |
fixed message id, category id mapping
Diffstat (limited to 'src/log')
-rwxr-xr-x | src/log/create_wolfmsg.pl | 10 | ||||
-rw-r--r-- | src/log/log.c | 91 | ||||
-rw-r--r-- | src/log/wolfmsg.mc | 10 |
3 files changed, 95 insertions, 16 deletions
diff --git a/src/log/create_wolfmsg.pl b/src/log/create_wolfmsg.pl index 0bca019..3da27bd 100755 --- a/src/log/create_wolfmsg.pl +++ b/src/log/create_wolfmsg.pl @@ -55,12 +55,12 @@ SeverityNames = ( Error = 0x3 : STATUS_SEVERITY_ERROR ) -;we get a already defined message? but where is Application defined? +;// we get a already defined message? but where is Application defined? ;// facility names -;FacilityNames = ( -; System = 0x0FF -; Application = 0xFFF -;) +FacilityNames = ( + System = 0x0FF + Application = 0xFFF +) EOF diff --git a/src/log/log.c b/src/log/log.c index 6b7e9a5..3c97f00 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -261,9 +261,85 @@ static WORD wolf_log_level_to_eventlog_type( wolf_log_level_t level ) { case WOLF_LOG_DEBUG3: case WOLF_LOG_DEBUG4: case WOLF_LOG_DEBUG5: return EVENTLOG_INFORMATION_TYPE; - default: return EVENTLOG_ERROR_TYPE; + default: return -1; } } + +/* + Values are 32 bit values layed out as follows: + + 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +---+-+-+-----------------------+-------------------------------+ + |Sev|C|R| Facility | Code | + +---+-+-+-----------------------+-------------------------------+ + + 1 1 0 0 + + where + + Sev - is the severity code + + 00 - Success + 01 - Informational + 10 - Warning + 11 - Error + + C - is the Customer code flag + + R - is a reserved bit + + Facility - is the facility code + + Code - is the facility's status code + + Define the facility codes + +SeverityNames = ( + Success = 0x0 : STATUS_SEVERITY_SUCCESS + Informational = 0x1 : STATUS_SEVERITY_INFORMATIONAL + Warning = 0x2 : STATUS_SEVERITY_WARNING + Error = 0x4 : STATUS_SEVERITY_ERROR +) + +;we get a already defined message? but where is Application defined? +;// facility names +;FacilityNames = ( +; System = 0x0FF +; Application = 0xFFF +;) + +*/ + +static DWORD wolf_log_category_to_eventlog_category( int category_id ) { + return category_id | 0x0FFF0000L; +} + +static DWORD wolf_log_event_id_to_eventlog_event_id( WORD severity, int message_id ) { + DWORD id; + + /* no clue, why the bitmask has to differ from the EVENTLOG_xxx + * constants, but so it is.. + * + * 00 - Success 0 + * 01 - Informational 4 + * 10 - Warning 2 + * 11 - Error 1 + */ + int s = 0; + switch( severity ) { + case EVENTLOG_ERROR_TYPE: s = 3; break; + case EVENTLOG_WARNING_TYPE: s = 2; break; + case EVENTLOG_INFORMATION_TYPE: s = 1; break; + } + + id = message_id | 0x0FFF0000L | ( s << 30 ); + +printf( "%d %x %ld\n", s, id, id ); + + return id; +} + #endif /* defined HAVE_EVENTLOG */ #if defined HAVE_SYSLOG_H @@ -406,7 +482,7 @@ static void registry_set_word( HKEY h, TCHAR *name, DWORD value ) { RegSetValueEx( h, name, 0, REG_DWORD, (LPBYTE)&value, sizeof( DWORD ) ); } -static void register_event_source( const char *log, const char *source, const char *path_to_dll ) { +static void register_event_source( const char *log, const char *source, const char *path_to_dll, int nof_categories ) { char key[256]; HKEY h = 0; DWORD disposition; @@ -421,7 +497,7 @@ static void register_event_source( const char *log, const char *source, const ch registry_set_expandable_string( h, "EventMessageFile", (char *)path_to_dll ); registry_set_expandable_string( h, "CategoryMessageFile", (char *)path_to_dll ); registry_set_word( h, "TypesSupported", (DWORD)7 ); - registry_set_word( h, "CategoryCount", (DWORD)2 ); + registry_set_word( h, "CategoryCount", (DWORD)nof_categories ); RegCloseKey( h ); } @@ -492,6 +568,7 @@ void wolf_log_openlogtoeventlog( const char *server, const char *log, const char *source, const char *path_to_dll, + int nof_categories, wolf_log_level_t level ) { eventlog_server = server; eventlog_log = log; @@ -502,7 +579,7 @@ void wolf_log_openlogtoeventlog( const char *server, * message DLL, how many categories we define and what types * of events we are supporting */ - register_event_source( log, source, path_to_dll ); + register_event_source( log, source, path_to_dll, nof_categories ); /* for logging the user of the process into the event log */ sid = get_current_sid( ); @@ -642,8 +719,10 @@ void wolf_log( wolf_log_level_t level, int category_id, int message_id, const ch if( !ReportEvent( event_source, /* event source handle */ wolf_log_level_to_eventlog_type( level ), - 0x0FFF0001L, /* event category */ - 0xCFFF0101L, /* event identifier */ + wolf_log_category_to_eventlog_category( category_id ), + wolf_log_event_id_to_eventlog_event_id( + wolf_log_level_to_eventlog_type( level ), + message_id ), sid, /* the security identifier */ 2, /* at the moment only one string */ 0, /* no binary raw data */ diff --git a/src/log/wolfmsg.mc b/src/log/wolfmsg.mc index 3d19623..72b372f 100644 --- a/src/log/wolfmsg.mc +++ b/src/log/wolfmsg.mc @@ -42,12 +42,12 @@ SeverityNames = ( Error = 0x3 : STATUS_SEVERITY_ERROR ) -;we get a already defined message? but where is Application defined? +;// we get a already defined message? but where is Application defined? ;// facility names -;FacilityNames = ( -; System = 0x0FF -; Application = 0xFFF -;) +FacilityNames = ( + System = 0x0FF + Application = 0xFFF +) ;// event messages from here |