3 /* layout_simple - a dumb log layout */
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "xbt/sysdep.h"
12 #include "gras/virtu.h"
15 extern const char *xbt_log_priority_names[7];
18 static char *xbt_log_layout_simple_doit(xbt_log_layout_t l,
21 static char res[1024];
22 static double begin_of_time = -1;
25 xbt_assert0(ev->priority>=0,
26 "Negative logging priority naturally forbidden");
27 xbt_assert1(ev->priority<sizeof(xbt_log_priority_names),
28 "Priority %d is greater than the biggest allowed value",
32 begin_of_time=gras_os_time();
35 p += sprintf(res,"[");;
36 /* Display the proc info if available */
37 if(strlen(xbt_procname()))
38 p += sprintf(p,"%s:%s:(%d) ",
39 gras_os_myname(), xbt_procname(),(*xbt_getpid)());
41 /* Display the date */
42 p += sprintf(p,"%f] ", gras_os_time()-begin_of_time);
45 /* Display file position if not INFO*/
46 if (ev->priority != xbt_log_priority_info)
47 p += sprintf(p, "%s:%d: ", ev->fileName, ev->lineNum);
49 /* Display category name */
50 p += sprintf(p, "[%s/%s] ",
51 ev->cat->name, xbt_log_priority_names[ev->priority] );
53 /* Display user-provided message */
54 p += vsprintf(p, fmt, ev->ap);
57 p += sprintf(p, "\n");
62 xbt_log_layout_t xbt_log_layout_simple_new(char *arg) {
63 xbt_log_layout_t res = xbt_new0(s_xbt_log_layout_t,1);
64 res->do_layout = xbt_log_layout_simple_doit;