1 /* layout_simple - a dumb log layout */
3 /* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */
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. */
8 #include "xbt/sysdep.h"
9 #include "src/xbt/log_private.hpp"
11 #include "simgrid/engine.h" /* simgrid_get_clock */
12 #include "simgrid/host.h" /* sg_host_self_get_name */
15 extern const char *xbt_log_priority_names[8];
16 extern int xbt_log_no_loc;
18 #define check_overflow(len) \
26 static int xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_t ev, const char* fmt)
29 int rem_size = ev->buffer_size;
36 /* Display the proc info if available */
37 procname = xbt_procname();
38 if (procname && strcmp(procname,"maestro")) {
39 len = snprintf(p, rem_size, "%s:%s:(%d) ", sg_host_self_get_name(), procname, xbt_getpid());
43 len = snprintf(p, rem_size, "%s::(%d) ", sg_host_self_get_name(), xbt_getpid());
47 /* Display the date */
48 len = snprintf(p, rem_size, "%f] ", simgrid_get_clock());
51 /* Display file position if not INFO */
52 if (ev->priority != xbt_log_priority_info && !xbt_log_no_loc) {
53 len = snprintf(p, rem_size, "%s:%d: ", ev->fileName, ev->lineNum);
57 /* Display category name */
58 len = snprintf(p, rem_size, "[%s/%s] ", ev->cat->name, xbt_log_priority_names[ev->priority]);
61 /* Display user-provided message */
62 len = vsnprintf(p, rem_size, fmt, ev->ap);
73 xbt_log_layout_t xbt_log_layout_simple_new(const char*)
75 xbt_log_layout_t res = xbt_new0(s_xbt_log_layout_t, 1);
76 res->do_layout = &xbt_log_layout_simple_doit;