3 /* file_appender - a dumb log appender which simply prints to stdout */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003, 2004 Martin Quinson. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "xbt/sysdep.h"
13 #include "xbt/error.h"
16 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(log_app,log,"default logging handler");
19 * The root category's default logging function.
22 extern const char *xbt_log_priority_names[7];
24 static void append_file(xbt_log_appender_t this, xbt_log_event_t ev,
28 struct xbt_log_appender_file_s {
29 xbt_log_appender_t* appender;
34 static s_xbt_log_appender_t xbt_log_appender_file = { append_file, NULL } ;
35 /* appender_data=FILE* */
37 xbt_log_appender_t xbt_log_default_appender = &xbt_log_appender_file;
39 static void append_file(xbt_log_appender_t this,
43 /* TODO: define a format field in struct for timestamp, etc.
44 struct DefaultLogAppender* this = (struct DefaultLogAppender*)this0;*/
46 if ((FILE*)(this->appender_data) == NULL)
47 this->appender_data = (void*)stderr;
49 xbt_assert0(ev->priority>=0,
50 "Negative logging priority naturally forbidden");
51 xbt_assert1(ev->priority<sizeof(xbt_log_priority_names),
52 "Priority %d is greater than the biggest allowed value",
55 fprintf(stderr, "%s:%d: ", ev->fileName, ev->lineNum);
56 fprintf(stderr, "[%s/%s] ",
57 ev->cat->name, xbt_log_priority_names[ev->priority]);
58 vfprintf(stderr, fmt, ev->ap);
59 fprintf(stderr, "\n");