/* file_appender - a dumb log appender which simply prints to stdout */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2003, 2004 Martin Quinson. */
+/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/error.h"
#include <stdio.h>
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log_app,log,"default logging handler");
+#include "gras/virtu.h"
/**
* The root category's default logging function.
extern const char *xbt_log_priority_names[7];
-static void append_file(xbt_log_appender_t this, xbt_log_event_t ev,
+static void append_file(xbt_log_appender_t this_appender, xbt_log_event_t ev,
const char *fmt);
/*
xbt_log_appender_t xbt_log_default_appender = &xbt_log_appender_file;
-static void append_file(xbt_log_appender_t this,
+static const char* xbt_logappender_verbose_information(void) {
+ static char buffer[256];
+ static double begin_of_time = -1;
+
+ if (begin_of_time<0)
+ begin_of_time=gras_os_time();
+
+ if(strlen(xbt_procname()))
+ sprintf(buffer,"%s:%s:(%ld) %f", gras_os_myname(),
+ xbt_procname(),gras_os_getpid(),gras_os_time()-begin_of_time);
+ else
+ buffer[0]=0;
+
+ return buffer;
+}
+
+static void append_file(xbt_log_appender_t this_appender,
xbt_log_event_t ev,
const char *fmt) {
/* TODO: define a format field in struct for timestamp, etc.
struct DefaultLogAppender* this = (struct DefaultLogAppender*)this0;*/
-
- if ((FILE*)(this->appender_data) == NULL)
- this->appender_data = (void*)stderr;
+
+ char *procname = (char*)xbt_logappender_verbose_information();
+ if (!procname)
+ procname = (char*)"";
+
+ if ((FILE*)(this_appender->appender_data) == NULL)
+ this_appender->appender_data = (void*)stderr;
xbt_assert0(ev->priority>=0,
"Negative logging priority naturally forbidden");
"Priority %d is greater than the biggest allowed value",
ev->priority);
- fprintf(stderr, "%s:%d: ", ev->fileName, ev->lineNum);
+ fprintf(stderr, "[%s] %s:%d: ", procname, ev->fileName, ev->lineNum);
fprintf(stderr, "[%s/%s] ",
- ev->cat->name, xbt_log_priority_names[ev->priority]);
+ ev->cat->name, xbt_log_priority_names[ev->priority] );
vfprintf(stderr, fmt, ev->ap);
fprintf(stderr, "\n");
}