Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2005 Pekka Riikonen
+ Copyright (C) 1997 - 2006 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
/* $Id$ */
-#include "silcincludes.h"
+#include "silc.h"
/* SilcLogSettings context */
typedef struct {
/* Cycle log file */
fprintf(log->fp,
"[%s] [%s] Cycling log file, over max log size (%lu kilobytes)\n",
- silc_get_time(0), log->typename, (unsigned long)log->maxsize / 1024);
+ silc_time_string(0), log->typename,
+ (unsigned long)log->maxsize / 1024);
fflush(log->fp);
fclose(log->fp);
memset(newname, 0, sizeof(newname));
- snprintf(newname, sizeof(newname) - 1, "%s.old", log->filename);
+ silc_silc_snprintf(newname, sizeof(newname) - 1, "%s.old", log->filename);
unlink(newname);
rename(log->filename, newname);
if (silclog.flushdelay < 2)
silclog.flushdelay = 2;
- silc_schedule_task_add(context, 0, silc_log_fflush_callback, context,
- silclog.flushdelay, 0, SILC_TASK_TIMEOUT,
- SILC_TASK_PRI_NORMAL);
+ silc_schedule_task_add_timeout(context, silc_log_fflush_callback, context,
+ silclog.flushdelay, 0);
}
/* Output log message to log file */
found:
if (silclog.timestamp)
- fprintf(fp, "[%s] [%s] %s\n", silc_get_time(0), typename, string);
+ fprintf(fp, "[%s] [%s] %s\n", silc_time_string(0), typename, string);
else
fprintf(fp, "[%s] %s\n", typename, string);
/* Set and initialize the specified log file. */
-bool silc_log_set_file(SilcLogType type, char *filename, SilcUInt32 maxsize,
- SilcSchedule scheduler)
+SilcBool silc_log_set_file(SilcLogType type, char *filename,
+ SilcUInt32 maxsize, SilcSchedule scheduler)
{
FILE *fp = NULL;
SilcLog log;
/* Add flush timeout */
if (scheduler) {
silc_schedule_task_del_by_callback(scheduler, silc_log_fflush_callback);
- silc_schedule_task_add(scheduler, 0, silc_log_fflush_callback, scheduler,
- 10, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+ silc_schedule_task_add_timeout(scheduler, silc_log_fflush_callback,
+ scheduler, 10, 0);
silclog.scheduled = TRUE;
}
/* Set timestamp */
-void silc_log_timestamp(bool enable)
+void silc_log_timestamp(SilcBool enable)
{
silclog.timestamp = enable;
}
/* Set quick logging */
-void silc_log_quick(bool enable)
+void silc_log_quick(SilcBool enable)
{
silclog.quick = enable;
}
/* Set debugging */
-void silc_log_debug(bool enable)
+void silc_log_debug(SilcBool enable)
{
silclog.debug = enable;
}
/* Set debug hexdump */
-void silc_log_debug_hexdump(bool enable)
+void silc_log_debug_hexdump(SilcBool enable)
{
silclog.debug_hexdump = enable;
}