Revision 5e2ac519

b/include/qemu/error-report.h
14 14
#define QEMU_ERROR_H
15 15

  
16 16
#include <stdarg.h>
17
#include <stdbool.h>
17 18
#include "qemu/compiler.h"
18 19

  
19 20
typedef struct Location {
......
40 41
void error_set_progname(const char *argv0);
41 42
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
42 43
const char *error_get_progname(void);
44
extern bool enable_timestamp_msg;
43 45

  
44 46
#endif
b/qemu-options.hx
3100 3100
'/objects' path.
3101 3101
ETEXI
3102 3102

  
3103
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
3104
    "-msg timestamp[=on|off]\n"
3105
    "                change the format of messages\n"
3106
    "                on|off controls leading timestamps (default:on)\n",
3107
    QEMU_ARCH_ALL)
3108
STEXI
3109
@item -msg timestamp[=on|off]
3110
@findex -msg
3111
prepend a timestamp to each log message.(default:on)
3112
ETEXI
3113

  
3103 3114
HXCOMM This is the last statement. Insert new options before this line!
3104 3115
STEXI
3105 3116
@end table
b/util/qemu-error.c
196 196
    }
197 197
}
198 198

  
199
bool enable_timestamp_msg;
199 200
/*
200 201
 * Print an error message to current monitor if we have one, else to stderr.
201 202
 * Format arguments like sprintf().  The result should not contain
......
206 207
void error_report(const char *fmt, ...)
207 208
{
208 209
    va_list ap;
210
    GTimeVal tv;
211
    gchar *timestr;
212

  
213
    if (enable_timestamp_msg) {
214
        g_get_current_time(&tv);
215
        timestr = g_time_val_to_iso8601(&tv);
216
        error_printf("%s ", timestr);
217
        g_free(timestr);
218
    }
209 219

  
210 220
    error_print_loc();
211 221
    va_start(ap, fmt);
b/vl.c
516 516
    },
517 517
};
518 518

  
519
static QemuOptsList qemu_msg_opts = {
520
    .name = "msg",
521
    .head = QTAILQ_HEAD_INITIALIZER(qemu_msg_opts.head),
522
    .desc = {
523
        {
524
            .name = "timestamp",
525
            .type = QEMU_OPT_BOOL,
526
        },
527
        { /* end of list */ }
528
    },
529
};
530

  
519 531
/**
520 532
 * Get machine options
521 533
 *
......
1503 1515
    }
1504 1516
}
1505 1517

  
1518

  
1519
static void configure_msg(QemuOpts *opts)
1520
{
1521
    enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true);
1522
}
1523

  
1506 1524
/***********************************************************/
1507 1525
/* USB devices */
1508 1526

  
......
2942 2960
    qemu_add_opts(&qemu_object_opts);
2943 2961
    qemu_add_opts(&qemu_tpmdev_opts);
2944 2962
    qemu_add_opts(&qemu_realtime_opts);
2963
    qemu_add_opts(&qemu_msg_opts);
2945 2964

  
2946 2965
    runstate_init();
2947 2966

  
......
3838 3857
                }
3839 3858
                configure_realtime(opts);
3840 3859
                break;
3860
            case QEMU_OPTION_msg:
3861
                opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
3862
                if (!opts) {
3863
                    exit(1);
3864
                }
3865
                configure_msg(opts);
3866
                break;
3841 3867
            default:
3842 3868
                os_parse_cmd_args(popt->index, optarg);
3843 3869
            }

Also available in: Unified diff