Mercurial > mplayer.hg
annotate mp_msg.c @ 17549:d012a3dd0901
synced with 1.1223
author | gpoirier |
---|---|
date | Tue, 07 Feb 2006 08:54:47 +0000 |
parents | de9a36b1082c |
children | f580a7755ac5 |
rev | line source |
---|---|
7200 | 1 |
17108
f9a03e3c8e23
1000l, reverting 2 more unrelated changes with last commit
ods15
parents:
17106
diff
changeset
|
2 //#define MSG_USE_COLORS |
1562 | 3 |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <stdarg.h> | |
7 | |
1925 | 8 #include "config.h" |
9 | |
8573
b2e4f9dab7ad
codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents:
7205
diff
changeset
|
10 #if defined(FOR_MENCODER) || defined(CODECS2HTML) |
16618 | 11 #undef HAVE_NEW_GUI |
8573
b2e4f9dab7ad
codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents:
7205
diff
changeset
|
12 #endif |
b2e4f9dab7ad
codec-cfg cannot be built when the gui is enabled - it fails to link with a
jkeil
parents:
7205
diff
changeset
|
13 |
16618 | 14 #ifdef HAVE_NEW_GUI |
16374
e2e231134056
Remove many annoying GTK includes in every compile line and remove GTK
ods15
parents:
14542
diff
changeset
|
15 #include "Gui/interface.h" |
1925 | 16 extern int use_gui; |
17 #endif | |
1562 | 18 #include "mp_msg.h" |
19 | |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
20 /* maximum message length of mp_msg */ |
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
21 #define MSGSIZE_MAX 3072 |
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
22 |
17120
637a2f4ff216
Some more cola for msglevel, codec-cfg can't even call mp_msg_init or it'll
ods15
parents:
17108
diff
changeset
|
23 int mp_msg_levels[MSGT_MAX]; // verbose level of this module. inited to 2 |
637a2f4ff216
Some more cola for msglevel, codec-cfg can't even call mp_msg_init or it'll
ods15
parents:
17108
diff
changeset
|
24 int mp_msg_level_all = MSGL_STATUS; |
637a2f4ff216
Some more cola for msglevel, codec-cfg can't even call mp_msg_init or it'll
ods15
parents:
17108
diff
changeset
|
25 int verbose = 0; |
1562 | 26 |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
27 void mp_msg_init(){ |
17106
05af35012e4f
new -msglevel option, constrols msg level for every msg module
ods15
parents:
16618
diff
changeset
|
28 int i; |
17440
de9a36b1082c
MPLAYER_VERBOSE, new enviorment variable to control verbosity before init
ods15
parents:
17120
diff
changeset
|
29 char *env = getenv("MPLAYER_VERBOSE"); |
de9a36b1082c
MPLAYER_VERBOSE, new enviorment variable to control verbosity before init
ods15
parents:
17120
diff
changeset
|
30 if (env) |
de9a36b1082c
MPLAYER_VERBOSE, new enviorment variable to control verbosity before init
ods15
parents:
17120
diff
changeset
|
31 verbose = atoi(env); |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
32 #ifdef USE_I18N |
10415 | 33 #ifdef MP_DEBUG |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
34 fprintf(stdout, "Using GNU internationalization\n"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
35 fprintf(stdout, "Original domain: %s\n", textdomain(NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
36 fprintf(stdout, "Original dirname: %s\n", bindtextdomain(textdomain(NULL),NULL)); |
10415 | 37 #endif |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
38 bindtextdomain("mplayer", PREFIX"/share/locale"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
39 textdomain("mplayer"); |
10415 | 40 #ifdef MP_DEBUG |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
41 fprintf(stdout, "Current domain: %s\n", textdomain(NULL)); |
10415 | 42 fprintf(stdout, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL),NULL)); |
43 #endif | |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
44 #endif |
17106
05af35012e4f
new -msglevel option, constrols msg level for every msg module
ods15
parents:
16618
diff
changeset
|
45 for(i=0;i<MSGT_MAX;i++) mp_msg_levels[i] = -2; |
1562 | 46 } |
47 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6306
diff
changeset
|
48 int mp_msg_test(int mod, int lev) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6306
diff
changeset
|
49 { |
17106
05af35012e4f
new -msglevel option, constrols msg level for every msg module
ods15
parents:
16618
diff
changeset
|
50 return lev <= (mp_msg_levels[mod] == -2 ? mp_msg_level_all + verbose : mp_msg_levels[mod]); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6306
diff
changeset
|
51 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6306
diff
changeset
|
52 |
16618 | 53 void mp_msg(int mod, int lev, const char *format, ... ){ |
5102 | 54 va_list va; |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
55 char tmp[MSGSIZE_MAX]; |
5102 | 56 |
17106
05af35012e4f
new -msglevel option, constrols msg level for every msg module
ods15
parents:
16618
diff
changeset
|
57 if (!mp_msg_test(mod, lev)) return; // do not display |
5286
30caf02c0eae
10l - va_start needs teh pointer to stack - not the translated message
arpi
parents:
5220
diff
changeset
|
58 va_start(va, format); |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
59 vsnprintf(tmp, MSGSIZE_MAX, mp_gettext(format), va); |
7195
a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
arpi
parents:
7058
diff
changeset
|
60 va_end(va); |
10853 | 61 tmp[MSGSIZE_MAX-2] = '\n'; |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
62 tmp[MSGSIZE_MAX-1] = 0; |
5102 | 63 |
16618 | 64 #ifdef HAVE_NEW_GUI |
5102 | 65 if(use_gui) |
16618 | 66 guiMessageBox(lev, tmp); |
5102 | 67 #endif |
68 | |
7200 | 69 #ifdef MSG_USE_COLORS |
10415 | 70 /* that's only a silly color test */ |
16379 | 71 #ifdef MP_ANNOY_ME |
7200 | 72 { int c; |
73 static int flag=1; | |
74 if(flag) | |
16379 | 75 for(c=0;c<24;c++) |
7200 | 76 printf("\033[%d;3%dm*** COLOR TEST %d ***\n",(c>7),c&7,c); |
77 flag=0; | |
78 } | |
79 #endif | |
16379 | 80 { unsigned char v_colors[10]={9,1,3,15,7,2,2,8,8,8}; |
81 static const char *lev_text[]= { | |
82 "FATAL", | |
83 "ERROR", | |
84 "WARN", | |
85 "HINT", | |
86 "INFO", | |
87 "STATUS", | |
88 "V", | |
89 "DGB2", | |
90 "DGB3", | |
91 "DGB4"}; | |
92 static const char *mod_text[]= { | |
93 "GLOBAL", | |
94 "CPLAYER", | |
95 "GPLAYER", | |
96 "VIDEOOUT", | |
97 "AUDIOOUT", | |
98 "DEMUXER", | |
99 "DS", | |
100 "DEMUX", | |
101 "HEADER", | |
102 "AVSYNC", | |
103 "AUTOQ", | |
104 "CFGPARSER", | |
105 "DECAUDIO", | |
106 "DECVIDEO", | |
107 "SEEK", | |
108 "WIN32", | |
109 "OPEN", | |
110 "DVD", | |
111 "PARSEES", | |
112 "LIRC", | |
113 "STREAM", | |
114 "CACHE", | |
115 "MENCODER", | |
116 "XACODEC", | |
117 "TV", | |
118 "OSDEP", | |
119 "SPUDEC", | |
120 "PLAYTREE", | |
121 "INPUT", | |
122 "VFILTER", | |
123 "OSD", | |
124 "NETWORK", | |
125 "CPUDETECT", | |
126 "CODECCFG", | |
127 "SWS", | |
128 "VOBSUB", | |
129 "SUBREADER", | |
130 "AFILTER", | |
131 "NETST", | |
132 "MUXER"}; | |
133 | |
16618 | 134 int c=v_colors[lev]; |
135 int c2=(mod+1)%15+1; | |
16379 | 136 static int header=1; |
16618 | 137 FILE *stream= (lev) <= MSGL_WARN ? stderr : stdout; |
16379 | 138 if(header){ |
16618 | 139 fprintf(stream, "\033[%d;3%dm%9s\033[0;37m: ",c2>>3,c2&7, mod_text[mod]); |
16379 | 140 } |
141 fprintf(stream, "\033[%d;3%dm",c>>3,c&7); | |
142 header= tmp[strlen(tmp)-1] == '\n' | |
17108
f9a03e3c8e23
1000l, reverting 2 more unrelated changes with last commit
ods15
parents:
17106
diff
changeset
|
143 /*||tmp[strlen(tmp)-1] == '\r'*/; |
7200 | 144 } |
145 #endif | |
16618 | 146 if (lev <= MSGL_WARN){ |
7195
a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
arpi
parents:
7058
diff
changeset
|
147 fprintf(stderr, "%s", tmp);fflush(stderr); |
a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
arpi
parents:
7058
diff
changeset
|
148 } else { |
a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
arpi
parents:
7058
diff
changeset
|
149 printf("%s", tmp);fflush(stdout); |
a5b2566f3c2b
print only fatal/error/warning to stderr, others go to stdout
arpi
parents:
7058
diff
changeset
|
150 } |
1562 | 151 } |