Cleanups.
This commit is contained in:
parent
f370219f17
commit
2a67c132f4
|
@ -209,7 +209,7 @@ Log_Entry::grow ( )
|
||||||
_sa = (char**)realloc( _sa, sizeof( char * ) * (_i + 2) );
|
_sa = (char**)realloc( _sa, sizeof( char * ) * (_i + 2) );
|
||||||
_sa[ _i + 1 ] = NULL;
|
_sa[ _i + 1 ] = NULL;
|
||||||
}
|
}
|
||||||
\
|
|
||||||
int
|
int
|
||||||
Log_Entry::size ( void ) const
|
Log_Entry::size ( void ) const
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ Log_Entry::size ( void ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 ];
|
*name = _sa[ n ];
|
||||||
*value = *name + strlen( *name ) + 1;
|
*value = *name + strlen( *name ) + 1;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
int size ( void ) const;
|
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 );
|
char **sa ( void );
|
||||||
|
|
||||||
/* #define ADD ( type, format, exp ) \ */
|
/* #define ADD ( type, format, exp ) \ */
|
||||||
|
|
|
@ -462,17 +462,33 @@ Loggable::flush ( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Loggable::log_print( char **o, char **n ) const
|
Loggable::log_print( const Log_Entry *o, const Log_Entry *n ) const
|
||||||
{
|
{
|
||||||
if ( n )
|
if ( ! _fp )
|
||||||
for ( ; *n; n++ )
|
return;
|
||||||
log( "%s %s%s", *n, *n + strlen( *n ) + 1, *(n + 1) ? " " : "" );
|
|
||||||
|
|
||||||
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( " << " );
|
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" );
|
log( "\n" );
|
||||||
|
@ -498,24 +514,21 @@ Loggable::log_end ( void )
|
||||||
if ( --_nest > 0 )
|
if ( --_nest > 0 )
|
||||||
return;
|
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( "%s 0x%X set ", class_name(), _id );
|
||||||
|
|
||||||
log_print( _old_state->sa(), _new_state->sa() );
|
log_print( _old_state, new_state );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _new_state )
|
if ( new_state )
|
||||||
delete _new_state;
|
delete new_state;
|
||||||
|
|
||||||
if ( _old_state )
|
if ( _old_state )
|
||||||
delete _old_state;
|
delete _old_state;
|
||||||
|
@ -529,32 +542,13 @@ Loggable::log_end ( void )
|
||||||
void
|
void
|
||||||
Loggable::log_create ( void ) const
|
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 );
|
log( "%s 0x%X create ", class_name(), _id );
|
||||||
|
|
||||||
char **sa;
|
|
||||||
|
|
||||||
Log_Entry e;
|
Log_Entry e;
|
||||||
|
|
||||||
get( e );
|
get( e );
|
||||||
|
|
||||||
sa = e.sa();
|
log_print( NULL, &e );
|
||||||
|
|
||||||
if ( sa )
|
|
||||||
{
|
|
||||||
log_print( NULL, sa );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
log( "\n" );
|
|
||||||
|
|
||||||
if ( Loggable::_level == 0 )
|
if ( Loggable::_level == 0 )
|
||||||
Loggable::flush();
|
Loggable::flush();
|
||||||
|
@ -573,7 +567,7 @@ Loggable::log_destroy ( void ) const
|
||||||
|
|
||||||
get( e );
|
get( e );
|
||||||
|
|
||||||
log_print( NULL, e.sa() );
|
log_print( NULL, &e );
|
||||||
|
|
||||||
if ( Loggable::_level == 0 )
|
if ( Loggable::_level == 0 )
|
||||||
Loggable::flush();
|
Loggable::flush();
|
||||||
|
|
|
@ -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 log ( const char *fmt, ... );
|
||||||
|
|
||||||
static void flush ( void );
|
static void flush ( void );
|
||||||
|
|
Loading…
Reference in New Issue