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 "gras_private.h"
14 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log_app,log);
18 * The root category's default logging function.
21 extern const char *gras_log_priority_names[7];
23 static void append_file(gras_log_appender_t* this, gras_log_event_t* ev,
27 struct gras_log_appender_file_s {
28 gras_log_appender_t* appender;
33 static gras_log_appender_t gras_log_appender_file = { append_file, NULL } ;
34 /* appender_data=FILE* */
36 gras_log_appender_t* gras_log_default_appender = &gras_log_appender_file;
38 static void append_file(gras_log_appender_t* this,
42 // TODO: define a format field in struct for timestamp, etc.
43 // struct DefaultLogAppender* this = (struct DefaultLogAppender*)this0;
45 if ((FILE*)(this->appender_data) == NULL)
46 this->appender_data = (void*)stderr;
48 gras_assert0(ev->priority>=0,
49 "Negative logging priority naturally forbidden");
50 gras_assert1(ev->priority<sizeof(gras_log_priority_names),
51 "Priority %d is greater than the biggest allowed value",
54 fprintf(stderr, "%s:%d: ", ev->fileName, ev->lineNum);
55 fprintf(stderr, "[%s/%s] ",
56 ev->cat->name, gras_log_priority_names[ev->priority]);
57 vfprintf(stderr, fmt, ev->ap);
58 fprintf(stderr, "\n");