* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
+ * oyvind.harboe@zylin.com *
+ * *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
#include "log.h"
#include "configuration.h"
#include "time_support.h"
+#include "command.h"
#include <stdio.h>
#include <stdlib.h>
}
else
{
- /* do not print count and time */
- fprintf(log_output, "%s %s:%d %s(): %s", log_strings[level+1], file, line, function, string);
+ if (strcmp(string, "\n")!=0)
+ {
+ /* print human readable output - but skip empty lines */
+ fprintf(log_output, "%s%s",
+ (level > LOG_LVL_USER)?log_strings[level+1]:"", string);
+ }
}
} else
{
LOG_USER_N("%s", "");
last_time=current_time;
}
+
+ /* also process TCL events (we have to do this from 'log.c' since its
+ * keep_alive() is the only routine guaranteed to be called at least
+ * once per second :( */
+ process_jim_events ();
}
/* reset keep alive timer without sending message */
current_time=timeval_ms();
last_time=current_time;
}
+
+/* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */
+void alive_sleep(int ms)
+{
+ int i;
+ for (i=0; i<ms; i+=500)
+ {
+ int sleep_a_bit=ms-i;
+ if (sleep_a_bit>500)
+ {
+ sleep_a_bit=500;
+ }
+ keep_alive();
+ usleep(sleep_a_bit*1000);
+ keep_alive();
+ }
+}