p_ibtrapgen->p_log = (osm_log_t *)cl_malloc(sizeof(osm_log_t));
osm_log_construct( p_ibtrapgen->p_log );
status = osm_log_init( p_ibtrapgen->p_log, p_opt->force_log_flush,
- 0x0001, p_opt->log_file );
+ 0x0001, p_opt->log_file, TRUE );
if( status != IB_SUCCESS )
return ( status );
IN osm_log_t* const p_log,
IN const boolean_t flush,
IN const uint8_t log_flags,
- IN const char *log_file)
+ IN const char *log_file,
+ IN const boolean_t accum_log_file )
{
p_log->level = log_flags;
p_log->flush = flush;
}
else
{
+ if (accum_log_file)
p_log->out_port = fopen(log_file,"a+");
+ else
+ p_log->out_port = fopen(log_file,"w+");
+
if (!p_log->out_port)
{
+ if (accum_log_file)
printf("Cannot open %s for appending. Permission denied\n", log_file);
+ else
+ printf("Cannot open %s for writing. Permission denied\n", log_file);
+
return(IB_UNKNOWN_ERROR);
}
}
uint8_t log_flags;
char * dump_files_dir;
char * log_file;
+ boolean_t accum_log_file;
cl_map_t port_pro_ignore_guids;
boolean_t port_profile_switch_nodes;
uint32_t max_port_profile;
* log_file
* Name of the log file (or NULL) for stdout.
*
+* accum_log_file
+* If TRUE (default) - the log file will be accumulated.
+* If FALSE - the log file will be erased before starting current opensm run.
+*
* port_pro_ignore_guids
* A map of guids to be ignored by port profiling.
*
cl_event_wheel_construct( &event_wheel );
/* init */
- osm_log_init( &log, TRUE, 0xff, NULL);
+ osm_log_init( &log, TRUE, 0xff, NULL, FALSE);
cl_event_wheel_init( &event_wheel, &log );
/* Start Playing */
" This option defines the log to be the given file.\n"
" By default the log goes to /var/log/osm.log.\n"
" For the log to go to standard output use -f stdout.\n\n");
+ printf( "-e\n"
+ "--erase_log_file\n"
+ " This option will cause deletion of the log file \n"
+ " (if it previously exists). By default, the log file \n"
+ " is accumulative.\n\n");
printf( "-v\n"
"--verbose\n"
" This option increases the log verbosity level.\n"
boolean_t cache_options = FALSE;
char *ignore_guids_file_name = NULL;
uint32_t val;
- const char * const short_option = "i:f:d:g:l:s:t:vVhorc";
+ const char * const short_option = "i:f:ed:g:l:s:t:vVhorc";
/*
In the array below, the 2nd parameter specified the number
{ "verbose", 0, NULL, 'v'},
{ "D", 1, NULL, 'D'},
{ "log_file", 1, NULL, 'f'},
+ { "erase_log_file",0, NULL, 'e'},
{ "maxsmps", 1, NULL, 'n'},
{ "V", 0, NULL, 'V'},
{ "help", 0, NULL, 'h'},
opt.log_file = optarg;
break;
+ case 'e':
+ opt.accum_log_file = FALSE;
+ printf(" Erasing existing(old) log file\n");
+ break;
+
case 'v':
log_flags = (log_flags <<1 )|1;
printf(" Verbose option -v (log flags = 0x%X)\n", log_flags );
osm_opensm_construct( p_osm );
status = osm_log_init( &p_osm->log, p_opt->force_log_flush,
- p_opt->log_flags, p_opt->log_file );
+ p_opt->log_flags, p_opt->log_file, p_opt->accum_log_file );
if( status != IB_SUCCESS )
return ( status );
p_opt->dump_files_dir = OSM_DEFAULT_TMP_DIR;
p_opt->log_file = OSM_DEFAULT_LOG_FILE;
+ p_opt->accum_log_file = TRUE;
p_opt->port_profile_switch_nodes = FALSE;
p_opt->max_port_profile = 0xffffffff;
p_opt->pfn_ui_pre_lid_assign = NULL;
__osm_subn_opts_unpack_charp(
"log_file" , p_key, p_val, &p_opts->log_file);
+ __osm_subn_opts_unpack_boolean(
+ "accum_log_file",
+ p_key, p_val, &p_opts->accum_log_file);
+
__osm_subn_opts_unpack_charp(
"dump_files_dir" ,
p_key, p_val, &p_opts->dump_files_dir);
"force_log_flush %s\n\n"
"# Log file to be used\n"
"log_file %s\n\n"
+ "accum_log_file %s\n\n"
"# The directory to hold the file OpenSM dumps\n"
"dump_files_dir %s\n\n"
"# If TRUE if OpenSM should disable multicast support\n"
p_opts->log_flags,
p_opts->force_log_flush ? "TRUE" : "FALSE",
p_opts->log_file,
+ p_opts->accum_log_file,
p_opts->dump_files_dir,
p_opts->no_multicast_option ? "TRUE" : "FALSE",
p_opts->disable_multicast ? "TRUE" : "FALSE"
osmtest_construct( p_osmt );
status = osm_log_init( &p_osmt->log, p_opt->force_log_flush,
- 0x0001, p_opt->log_file );
+ 0x0001, p_opt->log_file, TRUE );
if( status != IB_SUCCESS )
return ( status );
/* but we do not want any extra staff here */