Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill old $Id$ command dating from CVS
[simgrid.git] / src / xbt / xbt_log_appender_file.c
1 /* file_appender - a dumb log appender which simply prints to stdout        */
2
3 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "xbt/sysdep.h"
9 #include "xbt/log_private.h"
10 #include <stdio.h>
11
12 /**
13  * The root category's default logging function.
14  */
15
16 extern const char *xbt_log_priority_names[8];
17
18
19 static void append_file(xbt_log_appender_t this_appender, char *str)
20 {
21   fprintf((FILE *) (this_appender->data), "%s", str);
22 }
23
24 static void free_(xbt_log_appender_t this_)
25 {
26   if (this_->data != stderr)
27     fclose(this_->data);
28 }
29
30
31
32 xbt_log_appender_t xbt_log_appender_file_new(char *arg)
33 {
34   xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
35   res->do_append = append_file;
36   res->free_ = free_;
37   if (arg)
38     res->data = (void *) fopen(arg, "w");
39   else
40     res->data = (void *) stderr;
41   return res;
42 }