Search
lxdream.org :: lxdream/src/util.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/util.c
changeset 437:2c259474b474
prev425:17f019f4ed8d
next447:3e095bfcb476
author nkeynes
date Thu Oct 11 08:22:03 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Add speed meter to main window
Add sunken border around video area
Add debugger menu item
Move logging out to util.c
file annotate diff log raw
1.1 --- a/src/util.c Sun Oct 07 06:03:22 2007 +0000
1.2 +++ b/src/util.c Thu Oct 11 08:22:03 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: util.c,v 1.8 2007-10-07 06:03:22 nkeynes Exp $
1.6 + * $Id: util.c,v 1.9 2007-10-11 08:22:03 nkeynes Exp $
1.7 *
1.8 * Miscellaneous utility functions.
1.9 *
1.10 @@ -17,7 +17,15 @@
1.11 */
1.12
1.13 #include <ctype.h>
1.14 +#include <stdarg.h>
1.15 +#include <stdio.h>
1.16 +#include <stdlib.h>
1.17 +#include <time.h>
1.18 #include "dream.h"
1.19 +#include "sh4/sh4core.h"
1.20 +
1.21 +char *msg_levels[] = { "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
1.22 +int global_msg_level = EMIT_WARN;
1.23
1.24 void fwrite_string( const char *s, FILE *f )
1.25 {
1.26 @@ -81,3 +89,25 @@
1.27 fprintf( f, "\n" );
1.28 }
1.29 }
1.30 +
1.31 +
1.32 +void log_message( void *ptr, int level, const gchar *source, const char *msg, ... )
1.33 +{
1.34 + char buf[20], addr[10] = "", *p;
1.35 + const gchar *arr[4] = {buf, source, addr};
1.36 + int posn;
1.37 + time_t tm = time(NULL);
1.38 + va_list ap;
1.39 +
1.40 + if( level > global_msg_level ) {
1.41 + return; // ignored
1.42 + }
1.43 + va_start(ap, msg);
1.44 +
1.45 + strftime( buf, sizeof(buf), "%H:%M:%S", localtime(&tm) );
1.46 +
1.47 + fprintf( stderr, "%s %08X %-5s ", buf, sh4r.pc, msg_levels[level] );
1.48 + vfprintf( stderr, msg, ap );
1.49 + fprintf( stderr, "\n" );
1.50 + va_end(ap);
1.51 +}
.