summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/msg.c11
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/common/msg.c b/common/msg.c
index 9b93a3fb7a..a8ff492e7a 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -34,6 +34,7 @@
#include "options/options.h"
#include "osdep/terminal.h"
#include "osdep/io.h"
+#include "osdep/timer.h"
#include "msg.h"
#include "msg_control.h"
@@ -48,6 +49,7 @@ struct mp_log_root {
bool use_terminal; // make accesses to stderr/stdout
bool smode; // slave mode compatibility glue
bool module;
+ bool show_time;
bool termosd; // use terminal control codes for status line
bool header; // indicate that message header should be printed
int blank_lines; // number of lines useable by status
@@ -241,8 +243,12 @@ static void print_msg_on_terminal(struct mp_log *log, int lev, char *text)
set_msg_color(stream, lev);
do {
- if (header && prefix)
- fprintf(stream, "[%s] ", prefix);
+ if (header) {
+ if (root->show_time)
+ fprintf(stream, "[%" PRId64 "] ", mp_time_us());
+ if (prefix)
+ fprintf(stream, "[%s] ", prefix);
+ }
char *next = strchr(text, '\n');
int len = next ? next - text + 1 : strlen(text);
@@ -378,6 +384,7 @@ void mp_msg_update_msglevels(struct mpv_global *global)
root->module = opts->msg_module;
root->smode = opts->msg_identify;
root->use_terminal = opts->use_terminal;
+ root->show_time = opts->msg_time;
if (root->use_terminal) {
root->color = opts->msg_color && isatty(fileno(stdout));
root->termosd = !opts->slave_mode && isatty(fileno(stderr));
diff --git a/options/options.c b/options/options.c
index 202fb42c49..835ff21f9f 100644
--- a/options/options.c
+++ b/options/options.c
@@ -232,6 +232,7 @@ const m_option_t mp_opts[] = {
.type = &m_option_type_msglevels),
OPT_FLAG("msgcolor", msg_color, CONF_GLOBAL | CONF_PRE_PARSE),
OPT_FLAG("msgmodule", msg_module, CONF_GLOBAL),
+ OPT_FLAG("msgtime", msg_time, CONF_GLOBAL),
OPT_FLAG("identify", msg_identify, CONF_GLOBAL),
#if HAVE_PRIORITY
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
diff --git a/options/options.h b/options/options.h
index 23be601f46..3b9ddeedc7 100644
--- a/options/options.h
+++ b/options/options.h
@@ -50,6 +50,7 @@ typedef struct MPOpts {
int msg_identify;
int msg_color;
int msg_module;
+ int msg_time;
char **reset_options;
char **lua_files;