1 /* layout_simple - a dumb log layout */
3 /* Copyright (c) 2007-2023. 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 "src/xbt/log_private.hpp"
9 #include "xbt/sysdep.h"
10 #include <simgrid/actor.h>
11 #include <simgrid/s4u/Actor.hpp>
13 #include "simgrid/engine.h" /* simgrid_get_clock */
14 #include "simgrid/host.h" /* sg_host_self_get_name */
17 extern int xbt_log_no_loc;
19 #define check_overflow(len) \
27 static bool xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_t ev, const char* fmt)
30 int rem_size = ev->buffer_size;
37 /* Display the proc info if available */
38 procname = sg_actor_self_get_name();
39 if (procname && strcmp(procname,"maestro")) {
40 len = snprintf(p, rem_size, "%s:%s:(%ld) ", sg_host_self_get_name(), procname, sg_actor_self_get_pid());
42 } else if (not procname) {
43 len = snprintf(p, rem_size, "%s::(%ld) ", sg_host_self_get_name(), sg_actor_self_get_pid());
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 && not 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 auto* res = xbt_new0(s_xbt_log_layout_t, 1);
76 res->do_layout = &xbt_log_layout_simple_doit;