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.
 
 
 
 
 
 

61 lines
1.9 KiB

#include "objectCURSESLoggingService.h"
objectCURSESLoggingService::objectCURSESLoggingService() : WindowCLI(NULL){
m_bLogging = true;
#ifndef NEWT_CLI
create( 0, 49, 121, 20 );
#endif
m_iLinesCount = 20;
m_ppLines = (char **) malloc( m_iLinesCount * sizeof( char* ) );
};
objectCURSESLoggingService::objectCURSESLoggingService( int x, int y, int w, int h ): WindowCLI(NULL){
m_bLogging = true;
#ifndef NEWT_CLI
create( x, y, w, h );
#endif
m_iLinesCount = h;
m_ppLines = (char **) malloc( m_iLinesCount * sizeof( char* ) );
for( int index = 0; index < m_iLinesCount; index++){
m_ppLines[index] = NULL;
};
};
objectCURSESLoggingService::~objectCURSESLoggingService(){
for(int index = 0; index < m_iLinesCount; index++ ) {
if( m_ppLines[index]!= NULL ) free( m_ppLines[index] );
};
free( m_ppLines );
};
void objectCURSESLoggingService::paint( void ){
#ifndef NEWT_CLI
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 objectCURSESLoggingService::logMessage( CSTR Msg ){
logMessage( (const char *)Msg );
};
void objectCURSESLoggingService::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();
};
};