[MPlayer-dev-eng] MPLAYER_VERBOSE environment variable?
Chuck Blake
cb at mit.edu
Tue Jan 17 09:07:52 CET 2006
Hey,
I'm not sure if anyone else has any interest in increasing/decreasing the
default global log-level/verbosity that is in effect prior to finishing
the parsing of config files and command-line options.
With this patch one can instead set MPLAYER_VERBOSE to 1 in your shell.
It persists as the default setting of verbose if you don't specify any
command-line switches, but -v -v -v and so on will modify the initial
setting as usual, etc.
An environment variable seems the cleanest way to incorporate invocation-
specific preferences at this ultra early pre-config/CL parse stage of
mplayer. Indeed, it's hard to say anything else makes sense.
Yes, I do realize that (at present) there is very little code between
msg_init() and the parsing of the command line, but it's nice to have
different log-levels and control and as little code as is active already
has varying log-levels with no way to switch whether we see them or not.
Indeed, cpudetect.c has several mp_msg(*, MSGL_V, ...)'s already.
The only way to ever see those messages now is to either recompile with
a tweak to mp_msg.c:verbose=0 or to mess with mp_msg_level[MSGT_CPUDETECT]
in the debugger. This patch allows one to vary log levels for this code
in a simple, easy way. As the families of CPUs/microarchitectures all
become more and more diverse and branched out, there could be even more
reason for log-level separation, so a mechanism to control what actually
gets printed is good.
One could generalize this idea and do a whole system of environment
variables for the levels for all the different message categories at this
stage early stage and/or in addition to the command-line msglevel versions.
It wouldn't even be hard, but that seemed like overkill to me in terms
of controlling the logging for the small amount of logic preceeding
command parsing. A very cursory look suggests that only MSGT_CPLAYER
and MSGT_CPUDETECT are currently used (and MSGT_CFGPARSER, but that only
spits out errors which should always print). That being said, having
a way to tweak the global level early on seems quite reasonable to me.
The patch works fine against current CVS and clearly has no worrisome
interactions.
Anyway, loads of rationale for a really trival patch. It's only a
suggestion, but my guess/hope is that other people might like the
idea. It's kind of a rounding out of the relatively new fine-grained
logging command-line options.
Thanks for all your hard work on mplayer, guys...
cb
--
Index: mp_msg.c
===================================================================
RCS file: /cvsroot/mplayer/main/mp_msg.c,v
retrieving revision 1.31
diff -u -w -r1.31 mp_msg.c
--- mp_msg.c 7 Dec 2005 05:12:07 -0000 1.31
+++ mp_msg.c 17 Jan 2006 07:30:44 -0000
@@ -26,6 +26,9 @@
void mp_msg_init(){
int i;
+ char *env = getenv("MPLAYER_VERBOSE");
+ if (env)
+ verbose = atoi(env);
#ifdef USE_I18N
#ifdef MP_DEBUG
fprintf(stdout, "Using GNU internationalization\n");
More information about the MPlayer-dev-eng
mailing list