@ -137,7 +137,7 @@ void logfile::set_format_base_time(log_format *lf)
void logfile : : process_prefix ( off_t offset , shared_buffer_ref & sbr )
void logfile : : process_prefix ( off_t offset , shared_buffer_ref & sbr )
{
{
bool found = false ;
log_format : : scan_result_t found = log_format : : SCAN_NO_MATCH ;
if ( this - > lf_format . get ( ) ! = NULL ) {
if ( this - > lf_format . get ( ) ! = NULL ) {
/* We've locked onto a format, just use that scanner. */
/* We've locked onto a format, just use that scanner. */
@ -153,7 +153,7 @@ void logfile::process_prefix(off_t offset, shared_buffer_ref &sbr)
* are sufficiently different that there are no ambiguities . . .
* are sufficiently different that there are no ambiguities . . .
*/
*/
for ( iter = root_formats . begin ( ) ;
for ( iter = root_formats . begin ( ) ;
iter ! = root_formats . end ( ) & & ! found ;
iter ! = root_formats . end ( ) & & ( found ! = log_format : : SCAN_MATCH ) ;
+ + iter ) {
+ + iter ) {
if ( ! ( * iter ) - > match_name ( this - > lf_filename ) ) {
if ( ! ( * iter ) - > match_name ( this - > lf_filename ) ) {
continue ;
continue ;
@ -161,7 +161,8 @@ void logfile::process_prefix(off_t offset, shared_buffer_ref &sbr)
( * iter ) - > clear ( ) ;
( * iter ) - > clear ( ) ;
this - > set_format_base_time ( * iter ) ;
this - > set_format_base_time ( * iter ) ;
if ( ( * iter ) - > scan ( this - > lf_index , offset , sbr ) ) {
found = ( * iter ) - > scan ( this - > lf_index , offset , sbr ) ;
if ( found = = log_format : : SCAN_MATCH ) {
#if 0
#if 0
require ( this - > lf_index . size ( ) = = 1 | |
require ( this - > lf_index . size ( ) = = 1 | |
( this - > lf_index [ this - > lf_index . size ( ) - 2 ] <
( this - > lf_index [ this - > lf_index . size ( ) - 2 ] <
@ -176,7 +177,6 @@ void logfile::process_prefix(off_t offset, shared_buffer_ref &sbr)
auto_ptr < log_format > ( ( * iter ) - > specialized ( ) ) ;
auto_ptr < log_format > ( ( * iter ) - > specialized ( ) ) ;
this - > set_format_base_time ( this - > lf_format . get ( ) ) ;
this - > set_format_base_time ( this - > lf_format . get ( ) ) ;
this - > lf_content_id = hash_string ( string ( sbr . get_data ( ) , sbr . length ( ) ) ) ;
this - > lf_content_id = hash_string ( string ( sbr . get_data ( ) , sbr . length ( ) ) ) ;
found = true ;
/*
/*
* We ' ll go ahead and assume that any previous lines were
* We ' ll go ahead and assume that any previous lines were
@ -193,47 +193,50 @@ void logfile::process_prefix(off_t offset, shared_buffer_ref &sbr)
}
}
}
}
if ( found ) {
switch ( found ) {
if ( this - > lf_index . size ( ) > = 2 ) {
case log_format : : SCAN_MATCH :
logline & second_to_last = this - > lf_index [ this - > lf_index . size ( ) - 2 ] ;
if ( this - > lf_index . size ( ) > = 2 ) {
logline & latest = this - > lf_index . back ( ) ;
logline & second_to_last = this - > lf_index [ this - > lf_index . size ( ) - 2 ] ;
logline & latest = this - > lf_index . back ( ) ;
if ( latest < second_to_last ) {
if ( latest < second_to_last ) {
latest . set_time ( second_to_last . get_time ( ) ) ;
latest . set_time ( second_to_last . get_time ( ) ) ;
latest . set_millis ( second_to_last . get_millis ( ) ) ;
latest . set_millis ( second_to_last . get_millis ( ) ) ;
}
}
}
}
break ;
}
case log_format : : SCAN_NO_MATCH : {
logline : : level_t last_level = logline : : LEVEL_UNKNOWN ;
time_t last_time = this - > lf_index_time ;
short last_millis = 0 ;
uint8_t last_mod = 0 , last_opid = 0 ;
/* If the scanner didn't match, than we need to add it. */
if ( ! this - > lf_index . empty ( ) ) {
if ( ! found ) {
logline & ll = this - > lf_index . back ( ) ;
logline : : level_t last_level = logline : : LEVEL_UNKNOWN ;
time_t last_time = this - > lf_index_time ;
short last_millis = 0 ;
uint8_t last_mod = 0 , last_opid = 0 ;
if ( ! this - > lf_index . empty ( ) ) {
/*
logline & ll = this - > lf_index . back ( ) ;
* Assume this line is part of the previous one ( s ) and copy the
* metadata over .
/*
*/
* Assume this line is part of the previous one ( s ) and copy the
last_time = ll . get_time ( ) ;
* metadata over .
last_millis = ll . get_millis ( ) ;
*/
if ( this - > lf_format . get ( ) ! = NULL ) {
last_time = ll . get_time ( ) ;
last_level = ( logline : : level_t )
last_millis = ll . get_millis ( ) ;
( ll . get_level ( ) | logline : : LEVEL_CONTINUED ) ;
if ( this - > lf_format . get ( ) ! = NULL ) {
}
last_ level = ( logline : : level_t )
last_ mod = ll . get_module_id ( ) ;
( ll . get_level ( ) | logline : : LEVEL_CONTINUED ) ;
last_opid = ll . get_opid ( ) ;
}
}
last_mod = ll . get_module_id ( ) ;
this - > lf_index . push_back ( logline ( offset ,
last_opid = ll . get_opid ( ) ;
last_time ,
last_millis ,
last_level ,
last_mod ,
last_opid ) ) ;
break ;
}
}
this - > lf_index . push_back ( logline ( offset ,
case log_format : : SCAN_INCOMPLETE :
last_time ,
break ;
last_millis ,
last_level ,
last_mod ,
last_opid ) ) ;
}
}
}
}