100 lines
3.0 KiB
Plaintext
100 lines
3.0 KiB
Plaintext
$OpenBSD: patch-src-debuglog_c,v 1.2 2005/12/25 09:13:57 sturm Exp $
|
|
--- src/debuglog.c.orig Wed Nov 7 23:54:30 2001
|
|
+++ src/debuglog.c Sun Dec 25 10:08:57 2005
|
|
@@ -18,15 +18,17 @@
|
|
#include <syslog.h>
|
|
#include <stdio.h>
|
|
|
|
+#define DEBUG_BUFFER_LENGTH 150
|
|
+
|
|
static LONG lSuppress = DEBUGLOG_LOG_ENTRIES;
|
|
|
|
void DebugLogA( LPCSTR pcMessage, LPCSTR pcFile, LONG liLine ) {
|
|
|
|
if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
|
|
#ifdef USE_SYSLOG
|
|
- syslog( LOG_DEBUG, "%15s %3d: %s", pcFile, (int)liLine, pcMessage );
|
|
+ syslog( LOG_INFO, "%15s %3d: %s", pcFile, (int)liLine, pcMessage );
|
|
#else
|
|
- printf("%15s %3d: %s", pcFile, (int)liLine, pcMessage);
|
|
+ printf("%15s %3d: %s\n", pcFile, (int)liLine, pcMessage);
|
|
#endif
|
|
}
|
|
|
|
@@ -34,14 +36,16 @@ void DebugLogA( LPCSTR pcMessage, LPCSTR
|
|
|
|
void DebugLogB( LPCSTR pcFormat, LONG liValue, LPCSTR pcFile, LONG liLine ) {
|
|
|
|
- char pcBuffer[150];
|
|
+ char pcBuffer[DEBUG_BUFFER_LENGTH];
|
|
|
|
if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
|
|
- sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
|
|
+ snprintf(pcBuffer, sizeof(pcBuffer), "%15s %3d: %s", pcFile,
|
|
+ (int)liLine, pcFormat );
|
|
#ifdef USE_SYSLOG
|
|
- syslog( LOG_DEBUG, pcBuffer, liValue );
|
|
+ syslog( LOG_INFO, pcBuffer, liValue );
|
|
#else
|
|
printf(pcBuffer, liValue);
|
|
+ putchar('\n');
|
|
#endif
|
|
}
|
|
|
|
@@ -50,14 +54,16 @@ void DebugLogB( LPCSTR pcFormat, LONG li
|
|
void DebugLogC( LPCSTR pcFormat, LPCSTR pcMessage, LPCSTR pcFile,
|
|
LONG liLine ) {
|
|
|
|
- char pcBuffer[150];
|
|
+ char pcBuffer[DEBUG_BUFFER_LENGTH];
|
|
|
|
if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
|
|
- sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
|
|
+ snprintf(pcBuffer, sizeof(pcBuffer), "%15s %3d: %s", pcFile,
|
|
+ (int)liLine, pcFormat );
|
|
#ifdef USE_SYSLOG
|
|
- syslog( LOG_DEBUG, pcBuffer, pcMessage );
|
|
+ syslog( LOG_INFO, pcBuffer, pcMessage );
|
|
#else
|
|
printf(pcBuffer, pcMessage);
|
|
+ putchar('\n');
|
|
#endif
|
|
}
|
|
|
|
@@ -67,28 +73,26 @@ void DebugLogD( LPCSTR pcFormat, PUCHAR
|
|
LPCSTR pcFile, LONG liLine ) {
|
|
|
|
int i;
|
|
- char pcBuffer[150];
|
|
+ char pcBuffer[DEBUG_BUFFER_LENGTH];
|
|
char *tmpBuffer;
|
|
- /* tmpBuffer = (char *)malloc( ( 4+liLength ) * sizeof( PUCHAR ) ); */
|
|
|
|
if ( lSuppress == DEBUGLOG_LOG_ENTRIES ) {
|
|
- sprintf(pcBuffer, "%15s %3d: %s", pcFile, (int)liLine, pcFormat );
|
|
+ snprintf(pcBuffer, sizeof(pcBuffer), "%15s %3d: %s", pcFile,
|
|
+ (int)liLine, pcFormat );
|
|
#ifdef USE_SYSLOG
|
|
tmpBuffer = (char *)malloc( liLength*3 + 1);
|
|
- syslog( LOG_DEBUG, pcBuffer, pcFormat );
|
|
+ syslog( LOG_INFO, pcBuffer, pcFormat );
|
|
for (i=0; i < liLength; i++) {
|
|
- /* sprintf( tmpBuffer, "%x ", pucData[i] ); */
|
|
sprintf( tmpBuffer + i*3, "%02X ", pucData[i] );
|
|
|
|
}
|
|
- /* sprintf( tmpBuffer, "\n" ); */
|
|
- syslog( LOG_DEBUG, tmpBuffer );
|
|
+ syslog( LOG_INFO, tmpBuffer );
|
|
free( tmpBuffer );
|
|
#else
|
|
printf(pcBuffer, pcFormat);
|
|
for (i=0; i < liLength; i++) {
|
|
- printf("%x ", pucData[i]);
|
|
- } printf("\n");
|
|
+ printf("%02X ", pucData[i]);
|
|
+ } putchar('\n');
|
|
#endif
|
|
}
|
|
|