summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-17 14:03:07 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-17 14:03:07 +0000
commit8132d66186c8c08c44bb3504cb91e2e12bee11c1 (patch)
tree4ecd82e4ef102e45fd2ad6e61f9b5a14c216dcab /plugins
parentcc8d4f19bb722993be5aaa8b6790bec4d43c5684 (diff)
downloadrsyslog-8132d66186c8c08c44bb3504cb91e2e12bee11c1.tar.gz
rsyslog-8132d66186c8c08c44bb3504cb91e2e12bee11c1.tar.xz
rsyslog-8132d66186c8c08c44bb3504cb91e2e12bee11c1.zip
code cleanup debugging fixed, should now go through standard debugging
facility
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imklog/imklog.c82
-rw-r--r--plugins/imklog/ksym_mod.c48
2 files changed, 22 insertions, 108 deletions
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 3479a290..376d337f 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -92,7 +92,6 @@ static char *symfile = (char *) 0,
static enum LOGSRC {none, proc, kernel} logsrc;
-int debugging = 0;
int symbols_twice = 0;
@@ -284,10 +283,11 @@ static enum LOGSRC GetKernelLogSrc(void)
if ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 )
{
- fprintf(stderr, "rklogd: Cannot open proc file system, " \
- "%d - %s.\n", errno, strerror(errno));
- ksyslog(7, NULL, 0);
- exit(1);
+ char sz[512];
+ snprintf(sz, sizeof(sz), "rklogd: Cannot open proc file system, %d - %s.\n", errno, strerror(errno));
+ logmsgInternal(LOG_SYSLOG|LOG_ERR, sz, ADDDATE);
+ ksyslog(7, NULL, 0); /* TODO: check this, implement more */
+ return(none);
}
Syslog(LOG_INFO, "imklog %s, log source = %s started.", \
@@ -369,11 +369,8 @@ static void LogLine(char *ptr, int len)
*/
*line = 0; /* force null terminator */
- if ( debugging )
- {
- fputs("Line buffer full:\n", stderr);
- fprintf(stderr, "\tLine: %s\n", line);
- }
+ dbgprintf("Line buffer full:\n");
+ dbgprintf("\tLine: %s\n", line);
Syslog( LOG_INFO, "%s", line_buff );
line = line_buff;
@@ -567,10 +564,11 @@ static void LogKernelLine(void)
memset(log_buffer, '\0', sizeof(log_buffer));
if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
{
- if ( errno == EINTR )
+ char sz[512];
+ if(errno == EINTR)
return;
- fprintf(stderr, "rklogd: Error return from sys_sycall: " \
- "%d - %s\n", errno, strerror(errno));
+ snprintf(sz, sizeof(sz), "rklogd: Error return from sys_sycall: %d - %s\n", errno, strerror(errno));
+ logmsgInternal(LOG_SYSLOG|LOG_ERR, sz, ADDDATE);
}
else
LogLine(log_buffer, rdcnt);
@@ -603,62 +601,6 @@ static void LogProcLine(void)
}
-#if 0
-int main(int argc, char *argv[])
-{
- int ch,
- use_output = 0;
-
- char *log_level = (char *) 0,
- *output = (char *) 0;
-
- /* Parse the command-line. */
- while ((ch = getopt(argc, argv, "c:df:iIk:nopsvx2")) != EOF)
- switch((char)ch)
- {
- case '2': /* Print lines with symbols twice. */
- symbols_twice = 1;
- break;
- case 'c': /* Set console message level. */
- log_level = optarg;
- break;
- case 'd': /* Activity debug mode. */
- debugging = 1;
- break;
- case 'f': /* Define an output file. */
- output = optarg;
- use_output++;
- break;
- case 'k': /* Kernel symbol file. */
- symfile = optarg;
- break;
- case 'p':
- SetParanoiaLevel(1); /* Load symbols on oops. */
- break;
- case 's': /* Use syscall interface. */
- use_syscall = 1;
- break;
- case 'x':
- symbol_lookup = 0;
- break;
- }
-
-
- /* Set console logging level. */
- if ( log_level != (char *) 0 )
- {
- if ( (strlen(log_level) > 1) || \
- (strchr("12345678", *log_level) == (char *) 0) )
- {
- fprintf(stderr, "rklogd: Invalid console logging "
- "level <%s> specified.\n", log_level);
- return(1);
- }
- console_log_level = *log_level - '0';
- }
-}
-#endif
-
BEGINrunInput
CODESTARTrunInput
/* Determine where kernel logging information is to come from. */
@@ -690,10 +632,10 @@ CODESTARTrunInput
LogProcLine();
break;
case none:
+ /* TODO: We need to handle this case here somewhat more intelligent */
pause();
break;
}
-// CHKiRet(thrdSleep(pThrd, iMarkMessagePeriod, 0)); /* seconds, micro seconds */
}
finalize_it:
/* cleanup here */
diff --git a/plugins/imklog/ksym_mod.c b/plugins/imklog/ksym_mod.c
index 2cf559ce..a8f4790e 100644
--- a/plugins/imklog/ksym_mod.c
+++ b/plugins/imklog/ksym_mod.c
@@ -150,12 +150,6 @@ struct Module *sym_array_modules = (struct Module *) 0;
static int have_modules = 0;
-#if defined(TEST)
-static int debugging = 1;
-#else
-extern int debugging;
-#endif
-
/* Function prototypes. */
static void FreeModules(void);
@@ -179,9 +173,7 @@ static int symsort(const void *, const void *);
*
* True if loading is successful.
**************************************************************************/
-
-extern int InitMsyms()
-
+extern int InitMsyms(void)
{
auto int rtn,
tmp;
@@ -220,22 +212,17 @@ extern int InitMsyms()
"- %s\n", strerror(errno));
return(0);
}
- if ( debugging )
- fprintf(stderr, "Loading kernel module symbols - "
- "Size of table: %d\n", rtn);
+ dbgprintf("Loading kernel module symbols - Size of table: %d\n", rtn);
- ksym_table = (struct kernel_sym *) malloc(rtn * \
- sizeof(struct kernel_sym));
+ ksym_table = (struct kernel_sym *) malloc(rtn * sizeof(struct kernel_sym));
if ( ksym_table == (struct kernel_sym *) 0 )
{
- Syslog(LOG_WARNING, " Failed memory allocation for kernel " \
- "symbol table.\n");
+ Syslog(LOG_WARNING, " Failed memory allocation for kernel symbol table.\n");
return(0);
}
if ( (rtn = getsyms(ksym_table)) < 0 )
{
- Syslog(LOG_WARNING, "Error reading kernel symbols - %s\n", \
- strerror(errno));
+ Syslog(LOG_WARNING, "Error reading kernel symbols - %s\n", strerror(errno));
return(0);
}
@@ -279,12 +266,7 @@ extern int InitMsyms()
}
-static int symsort(p1, p2)
-
- const void *p1;
-
- const void *p2;
-
+static int symsort(const void *p1, const void *p2)
{
auto const struct sym_table *sym1 = p1,
*sym2 = p2;
@@ -307,9 +289,7 @@ static int symsort(p1, p2)
*
* Return: void
**************************************************************************/
-
-static void FreeModules()
-
+static void FreeModules(void)
{
auto int nmods,
nsyms;
@@ -436,7 +416,6 @@ static int AddModule(unsigned long address, char *symbol)
AddSymbol(mp, address, symbol);
}
-
return(1);
}
@@ -461,11 +440,7 @@ static int AddModule(unsigned long address, char *symbol)
* A boolean value is assumed. True if the addition is
* successful. False if not.
**************************************************************************/
-
-static int AddSymbol(mp, address, symbol)
- struct Module *mp;
- unsigned long address;
- char *symbol;
+static int AddSymbol(struct Module *mp, unsigned long address, char *symbol)
{
auto int tmp;
@@ -513,10 +488,7 @@ static int AddSymbol(mp, address, symbol)
* If a match is found the pointer to the symbolic name most
* closely matching the address is returned.
**************************************************************************/
-
-extern char * LookupModuleSymbol(value, sym)
- unsigned long value;
- struct symbol *sym;
+extern char * LookupModuleSymbol(unsigned long value, struct symbol *sym)
{
auto int nmod,
nsym;
@@ -614,5 +586,5 @@ extern char * LookupModuleSymbol(value, sym)
}
/* It has been a hopeless exercise. */
- return((char *) 0);
+ return(NULL);
}