summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-28 22:45:34 +0100
committerwm4 <wm4@nowhere>2014-02-28 22:45:34 +0100
commit97409ec4e652a2d56c3d77764cf9858b19b5cea9 (patch)
tree023a2334844ba3ef355fc10310a87a2e0a203bcc /common
parent1e2d409fb4f08dd73554c8c065292af325bf9f12 (diff)
downloadmpv-97409ec4e652a2d56c3d77764cf9858b19b5cea9.tar.bz2
mpv-97409ec4e652a2d56c3d77764cf9858b19b5cea9.tar.xz
msg: add --msgtime option to add timestamps to each output message
Will be helpful to track down strange wait times and such issues, as well when you have develop something timing related. (Then you may print timestamps in your debug output, and the --msgtime timestamps will help giving context.)
Diffstat (limited to 'common')
-rw-r--r--common/msg.c11
1 files changed, 9 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));