You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

70 lines
2.4 KiB

#include "objectCliLoggingServices.h"
objectCliLoggingService::objectCliLoggingService() : WindowCLI(NULL){
m_bLogging = true;
m_iLinesCount = 22;
m_ppLines = (char **) malloc( m_iLinesCount * sizeof( char* ) );
m_x = 3;
m_y = 30;
m_w = 121;
m_h = 22;
#ifdef NEWT_CLI
for( int index = 0; index < m_iLinesCount; index++){
m_ppLines[index] = NULL;
m_t[index] = newtTextbox( 1, index, 118, 1, 0 );
newtFormAddComponents( m_oForm, m_t[index], NULL );
};
m_b1 = newtCompactButton( 3, 21, "Refresh" );
m_b2 = newtCompactButton( 23, 21, "Close" );
newtFormAddComponents( m_oForm, m_b1, m_b2, NULL );
//paint();
#else
create( 0, 49, 121, 20 );
#endif
};
objectCliLoggingService::~objectCliLoggingService(){
for(int index = 0; index < m_iLinesCount; index++ ) {
if( m_ppLines[index]!= NULL ) free( m_ppLines[index] );
};
free( m_ppLines );
};
void objectCliLoggingService::paint( void ){
#ifdef NEWT_CLI
//newtOpenWindow( m_x, m_y, m_w, m_h, "Log Messages" );
newtCenteredWindow( m_w, m_h, "Log Messages" );
for( int index = 0; index < (m_iLinesCount-1); index++) {
if( m_ppLines[index]!= NULL ) newtTextboxSetText( m_t[index], m_ppLines[index] );
};
newtDrawForm( m_oForm );
#else
createBox( true );
for( int index = 0; index < (m_iLinesCount-1); index++) {
if( m_ppLines[index]!= NULL ) mvwprintw( m_pWND, index+1 , 1, m_ppLines[index] );
};
wrefresh( m_pWND );
#endif
};
void objectCliLoggingService::logMessage( CSTR Msg ){
logMessage( (const char *)Msg );
};
void objectCliLoggingService::logMessage( const char *Msg ){
if ( m_bLogging ){
if( m_ppLines[m_iLinesCount-1]!= NULL ) free( m_ppLines[m_iLinesCount-1]);
for(int index = m_iLinesCount-1; index > 0; index--) {
m_ppLines[index] = m_ppLines[index-1];
};
m_ppLines[0] = (char *) malloc(512);
if( m_ppLines[0] != NULL ){
time_t LocalTime;
tm *gmt_time;
time( &LocalTime );
gmt_time = gmtime( &LocalTime );
sprintf( m_ppLines[0], "%04d-%02d-%02d %02d:%02d:%02d %s\n", 1900+gmt_time->tm_year, 1+gmt_time->tm_mon, gmt_time->tm_mday, gmt_time->tm_hour, gmt_time->tm_min, gmt_time->tm_sec, Msg );
};
//paint();
};
};