Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : cosmetics, tab forgotten
[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) 2007-2011. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include "xbt/sysdep.h"
10 #include "xbt/log_private.h"
11 #include <stdio.h>
12
13 /**
14  * The root category's default logging function.
15  */
16
17 extern const char *xbt_log_priority_names[8];
18
19
20 static void append_file(xbt_log_appender_t this_appender, char *str)
21 {
22   fputs(str, (FILE *) (this_appender->data));
23 }
24
25 static void free_(xbt_log_appender_t this_)
26 {
27   if (this_->data != stderr)
28     fclose(this_->data);
29 }
30
31
32
33 xbt_log_appender_t xbt_log_appender_file_new(char *arg)
34 {
35   xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
36   res->do_append = append_file;
37   res->free_ = free_;
38   if (arg)
39     res->data = (void *) fopen(arg, "w");
40   else
41     res->data = (void *) stderr;
42   return res;
43 }