Search
lxdream.org :: lxdream :: r556:72dbf70344db
lxdream 0.9.1
released Jun 29
Download Now
changeset556:72dbf70344db lxdream-mmu
parent555:309c97260912
child557:37c162b2f1b8
authornkeynes
dateTue Jan 01 04:49:57 2008 +0000 (12 years ago)
branchlxdream-mmu
Add command line option to control default log level
src/lxdream.h
src/main.c
src/util.c
1.1 --- a/src/lxdream.h Tue Jan 01 04:32:01 2008 +0000
1.2 +++ b/src/lxdream.h Tue Jan 01 04:49:57 2008 +0000
1.3 @@ -67,6 +67,7 @@
1.4 #define MODULE_NAME "*****"
1.5 #endif
1.6
1.7 +gboolean set_global_log_level( const gchar *level );
1.8 void log_message( void *, int level, const char *source, const char *msg, ... );
1.9
1.10 #define FATAL( ... ) log_message( NULL, EMIT_FATAL, MODULE_NAME, __VA_ARGS__ )
2.1 --- a/src/main.c Tue Jan 01 04:32:01 2008 +0000
2.2 +++ b/src/main.c Tue Jan 01 04:49:57 2008 +0000
2.3 @@ -34,7 +34,7 @@
2.4
2.5 #define S3M_PLAYER "s3mplay.bin"
2.6
2.7 -char *option_list = "a:m:s:A:V:puhbd:c:t:xD";
2.8 +char *option_list = "a:m:s:A:V:v:puhbd:c:t:xD";
2.9 struct option longopts[1] = { { NULL, 0, 0, 0 } };
2.10 char *aica_program = NULL;
2.11 char *s3m_file = NULL;
2.12 @@ -109,6 +109,11 @@
2.13 time_secs = (uint32_t)t;
2.14 time_nanos = (int)((t - time_secs) * 1000000000);
2.15 break;
2.16 + case 'v': /* Log verbosity */
2.17 + if( !set_global_log_level(optarg) ) {
2.18 + ERROR( "Unrecognized log level '%s'", optarg );
2.19 + }
2.20 + break;
2.21 case 'x': /* Disable translator */
2.22 use_xlat = FALSE;
2.23 break;
3.1 --- a/src/util.c Tue Jan 01 04:32:01 2008 +0000
3.2 +++ b/src/util.c Tue Jan 01 04:49:57 2008 +0000
3.3 @@ -278,6 +278,30 @@
3.4 return buffer;
3.5 }
3.6
3.7 +int get_log_level_from_string( const gchar *str )
3.8 +{
3.9 + switch( tolower(str[0]) ) {
3.10 + case 'd': return EMIT_DEBUG;
3.11 + case 'e': return EMIT_ERR;
3.12 + case 'f': return EMIT_FATAL;
3.13 + case 'i': return EMIT_INFO;
3.14 + case 't': return EMIT_TRACE;
3.15 + case 'w': return EMIT_WARN;
3.16 + default: return -1;
3.17 + }
3.18 +}
3.19 +
3.20 +gboolean set_global_log_level( const gchar *str )
3.21 +{
3.22 + int l = get_log_level_from_string(str);
3.23 + if( l == -1 ) {
3.24 + return FALSE;
3.25 + } else {
3.26 + global_msg_level = l;
3.27 + return TRUE;
3.28 + }
3.29 +}
3.30 +
3.31 void log_message( void *ptr, int level, const gchar *source, const char *msg, ... )
3.32 {
3.33 char buf[20];
.