Cleanups.

This commit is contained in:
Jonathan Moore Liles 2008-06-03 23:28:28 -05:00
parent f370219f17
commit 2a67c132f4
4 changed files with 38 additions and 44 deletions

View File

@ -209,7 +209,7 @@ Log_Entry::grow ( )
_sa = (char**)realloc( _sa, sizeof( char * ) * (_i + 2) );
_sa[ _i + 1 ] = NULL;
}
\
int
Log_Entry::size ( void ) const
{
@ -217,7 +217,7 @@ Log_Entry::size ( void ) const
}
void
Log_Entry::get ( int n, const char **name, const char **value )
Log_Entry::get ( int n, const char **name, const char **value ) const
{
*name = _sa[ n ];
*value = *name + strlen( *name ) + 1;

View File

@ -64,7 +64,7 @@ public:
int size ( void ) const;
void get ( int n, const char **name, const char **value );
void get ( int n, const char **name, const char **value ) const;
char **sa ( void );
/* #define ADD ( type, format, exp ) \ */

View File

@ -462,17 +462,33 @@ Loggable::flush ( void )
}
void
Loggable::log_print( char **o, char **n ) const
Loggable::log_print( const Log_Entry *o, const Log_Entry *n ) const
{
if ( n )
for ( ; *n; n++ )
log( "%s %s%s", *n, *n + strlen( *n ) + 1, *(n + 1) ? " " : "" );
if ( ! _fp )
return;
if ( o && *o )
if ( n )
for ( int i = 0; i < n->size(); ++i )
{
const char *s, *v;
n->get( i, &s, &v );
log( "%s %s%s", s, v, n->size() == i + 1 ? "" : " " );
}
if ( o && o->size() )
{
if ( n ) log( " << " );
for ( ; *o; o++ )
log( "%s %s%s", *o, *o + strlen( *o ) + 1, *(o + 1) ? " " : "" );
for ( int i = 0; i < o->size(); ++i )
{
const char *s, *v;
o->get( i, &s, &v );
log( "%s %s%s", s, o->size() == i + 1 ? "" : " " );
}
}
log( "\n" );
@ -498,24 +514,21 @@ Loggable::log_end ( void )
if ( --_nest > 0 )
return;
Log_Entry *_new_state;
Log_Entry *new_state;
new_state = new Log_Entry;
get( *new_state );
if ( *_old_state != *new_state )
{
_new_state = new Log_Entry;
get( *_new_state );
}
if ( *_old_state != *_new_state )
{
// indent();
log( "%s 0x%X set ", class_name(), _id );
log_print( _old_state->sa(), _new_state->sa() );
log_print( _old_state, new_state );
}
if ( _new_state )
delete _new_state;
if ( new_state )
delete new_state;
if ( _old_state )
delete _old_state;
@ -529,32 +542,13 @@ Loggable::log_end ( void )
void
Loggable::log_create ( void ) const
{
// indent();
/* if ( Loggable::_level ) */
/* { */
/* /\* defer until the block ends--this is really only required for capturing... *\/ */
/* } */
log( "%s 0x%X create ", class_name(), _id );
char **sa;
Log_Entry e;
get( e );
sa = e.sa();
if ( sa )
{
log_print( NULL, sa );
}
else
log( "\n" );
log_print( NULL, &e );
if ( Loggable::_level == 0 )
Loggable::flush();
@ -573,7 +567,7 @@ Loggable::log_destroy ( void ) const
get( e );
log_print( NULL, e.sa() );
log_print( NULL, &e );
if ( Loggable::_level == 0 )
Loggable::flush();

View File

@ -100,7 +100,7 @@ private:
}
}
void log_print( char **o, char **n ) const;
void log_print( const Log_Entry *o, const Log_Entry *n ) const;
static void log ( const char *fmt, ... );
static void flush ( void );