1#include "main-header.h"
9static byte enabled = 0;
35 printf(
"Logging disabled.\r\n");
43 printf(
"Logging enabled.\r\n");
46static void printbuf() {
47 printf(
"************ LOGBUF ********\r\n");
48 printf(
"%s\r\n", buf);
49 printf(
"********** END LOGBUF ******\r\n");
60 if (strlen(buf) == 0) {
64 if (logcommand == NULL) {
65 printf(
"No command left to allocate to log.\r\n");
71 logcommand->
target = lognodeid;
73 send_command_quietly(logcommand);
79static void overflow() {
80 printf(
"LOGGING OVERFLOW (%i).\r\n", strlen(buf));
87void iplog(
const char *format, ...) {
91 va_start(args, format);
92 vsnprintf((
char *)&zbuf, 260, format, args);
94 print((
const char *)&zbuf);
98 int bsize =
sizeof(buf);
100 va_start(args, format);
102 if (i > (bsize - 5)) {
108 if (i >= (bsize - 10)) {
109 if (i > (bsize - 10)) {
124 vsnprintf(buf + i, (bsize - i), format, args);
void logging_set_node(long nodeid)
log to a given node. Usually this would be an app or a server
void logging_init()
initialise logging. logging is disabled after calling this function
void logging_off()
disable logging and logging processing. guarantees that no buffers are used for logging
void free_command(struct command *com)
free a command
void command_add_arg(struct command *com, const char *format,...)
adds an arg to a partially initialised command structure
void logging_event_loop()
sends current buffer and empties it
void command_init(struct command *com)
initialize a command structure with default values
void logging_on()
enable logging and logging processing. buffers are used for logging
struct command * alloc_command()
allocate a free command
void iplog(const char *format,...)
log something to a remote node