Skip to content

Commit

Permalink
replaced remaining INFO_PRINTS, renamed macros INFO_PRINT for logging
Browse files Browse the repository at this point in the history
without newline, INFO_PRINTLN for newline addition.
Replaced also INFO_PRINT_TRACE and renamed it to INFO_PRINTLN_TRACE
  • Loading branch information
turleypol committed Jan 7, 2024
1 parent 45b063b commit 9bc6e30
Show file tree
Hide file tree
Showing 88 changed files with 613 additions and 613 deletions.
2 changes: 1 addition & 1 deletion pol-core/bscript/compiler/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void Compiler::display_outcome( const std::string& filename, Report& report )
auto msg = fmt::format( "{}: {} errors", filename, report.error_count() );
if ( compilercfg.DisplayWarnings || compilercfg.ErrorOnWarning )
msg += fmt::format( ", {} warnings", report.warning_count() );
INFO_PRINT2( msg + '.' );
INFO_PRINTLN( msg + '.' );
}

} // namespace Pol::Bscript::Compiler
20 changes: 10 additions & 10 deletions pol-core/bscript/compiler/astbuilder/SourceFileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,24 @@ std::optional<std::string> SourceFileProcessor::locate_include_file(
std::string try_filename_full = pkg->dir() + "include/" + path;

if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Searching for {}", filename_full );
INFO_PRINTLN( "Searching for {}", filename_full );

if ( !Clib::FileExists( filename_full.c_str() ) )
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Searching for {}", try_filename_full );
INFO_PRINTLN( "Searching for {}", try_filename_full );
if ( Clib::FileExists( try_filename_full.c_str() ) )
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Found {}", try_filename_full );
INFO_PRINTLN( "Found {}", try_filename_full );

filename_full = try_filename_full;
}
}
else
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Found {}", filename_full );
INFO_PRINTLN( "Found {}", filename_full );

if ( Clib::FileExists( try_filename_full.c_str() ) )
report.warning( source_location, "Found '", filename_full, "' and '", try_filename_full,
Expand All @@ -218,9 +218,9 @@ std::optional<std::string> SourceFileProcessor::locate_include_file(

if ( compilercfg.VerbosityLevel >= 10 )
{
INFO_PRINT2( "Searching for {}", filename_full );
INFO_PRINTLN( "Searching for {}", filename_full );
if ( Clib::FileExists( filename_full.c_str() ) )
INFO_PRINT2( "Found {}", filename_full );
INFO_PRINTLN( "Found {}", filename_full );
}
}
}
Expand All @@ -234,17 +234,17 @@ std::optional<std::string> SourceFileProcessor::locate_include_file(
else
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Searching for {}", filename_full );
INFO_PRINTLN( "Searching for {}", filename_full );

if ( !Clib::FileExists( filename_full.c_str() ) )
{
std::string try_filename_full = compilercfg.IncludeDirectory + filename_part;
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Searching for {}", try_filename_full );
INFO_PRINTLN( "Searching for {}", try_filename_full );
if ( Clib::FileExists( try_filename_full.c_str() ) )
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Found {}", try_filename_full );
INFO_PRINTLN( "Found {}", try_filename_full );

// cout << "Using " << try_filename << endl;
filename_full = try_filename_full;
Expand All @@ -253,7 +253,7 @@ std::optional<std::string> SourceFileProcessor::locate_include_file(
else
{
if ( compilercfg.VerbosityLevel >= 10 )
INFO_PRINT2( "Found {}", filename_full );
INFO_PRINTLN( "Found {}", filename_full );
}
}
if ( SourceFile::enforced_case_sensitivity_mismatch( source_location, filename_full, report ) )
Expand Down
6 changes: 3 additions & 3 deletions pol-core/bscript/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void display_executor_instances()
{
// Fix for crashes due to orphaned script instances.
if ( !ex->empty_scriptname() )
INFO_PRINT2( ex->scriptname() );
INFO_PRINTLN( ex->scriptname() );
}
}

Expand Down Expand Up @@ -2479,7 +2479,7 @@ void Executor::ins_call_method( const Instruction& ins )
void Executor::ins_statementbegin( const Instruction& ins )
{
if ( debug_level >= SOURCELINES && ins.token.tokval() )
INFO_PRINT2( ins.token.tokval() );
INFO_PRINTLN( ins.token.tokval() );
}

// case CTRL_PROGEND:
Expand Down Expand Up @@ -2998,7 +2998,7 @@ void Executor::execInstr()
const Instruction& ins = prog_->instr.at( PC );
#endif
if ( debug_level >= INSTRUCTIONS )
INFO_PRINT2( "{}: {}", PC, ins.token );
INFO_PRINTLN( "{}: {}", PC, ins.token );

if ( debugging_ )
{
Expand Down
4 changes: 2 additions & 2 deletions pol-core/bscript/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ void Expression::remove_non_emitting_tokens()

void Expression::dump_tokens() const
{
INFO_PRINT2( "Expression with {} tokens:", tokens.size() );
INFO_PRINTLN( "Expression with {} tokens:", tokens.size() );
for ( unsigned i = 0; i < tokens.size(); ++i )
{
Token* tk = tokens[i];
INFO_PRINT2( "{:>4} ({:>2}): {}", i, get_num_tokens( i ), *tk );
INFO_PRINTLN( "{:>4} ({:>2}): {}", i, get_num_tokens( i ), *tk );
}
}

Expand Down
6 changes: 3 additions & 3 deletions pol-core/bscript/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ typedef std::unordered_map<unsigned int, BObjectImp*> bobjectimps;
bobjectimps bobjectimp_instances;
int display_bobjectimp_instance( BObjectImp* imp )
{
INFO_PRINT2( "{}: {}", imp->instance(), imp->getStringRep() );
INFO_PRINTLN( "{}: {}", imp->instance(), imp->getStringRep() );
return 0;
}
void display_bobjectimp_instances()
{
INFO_PRINT2( "bobjectimp instances: {}", bobjectimp_instances.size() );
INFO_PRINTLN( "bobjectimp instances: {}", bobjectimp_instances.size() );
for ( bobjectimps::iterator itr = bobjectimp_instances.begin(); itr != bobjectimp_instances.end();
++itr )
{
Expand Down Expand Up @@ -1436,7 +1436,7 @@ long ObjArray::contains( const BObjectImp& imp ) const
BObject* bo = ( itr->get() );
if ( bo == nullptr )
{
INFO_PRINT2( "{} - '{} in array{{}}' check. Invalid data at index {}",
INFO_PRINTLN( "{} - '{} in array{{}}' check. Invalid data at index {}",
Clib::scripts_thread_script, imp, ( itr - ref_arr.begin() ) + 1 );
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions pol-core/clib/logfacility.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ void initLogging( LogFacility* logger ); // initalize the logging
// log into pol.log
#define POLLOG Clib::Logging::Message<Clib::Logging::LogSink_pollog>().message()

// log only into std::cout
#define INFO_PRINT Clib::Logging::Message<Clib::Logging::LogSink_cout>().message()
#define INFO_PRINT2 Clib::Logging::Message2<Clib::Logging::LogSink_cout>::logmsg<true>
#define INFO_PRINT_N2 Clib::Logging::Message2<Clib::Logging::LogSink_cout>::logmsg<false>
// log only into std::cout with \n addition
#define INFO_PRINTLN Clib::Logging::Message2<Clib::Logging::LogSink_cout>::logmsg<true>
// log only into std::cout without \n addition
#define INFO_PRINT Clib::Logging::Message2<Clib::Logging::LogSink_cout>::logmsg<false>
// log only into std::cout if level is equal or higher
#define INFO_PRINT_TRACE( n ) \
#define INFO_PRINTLN_TRACE( n ) \
if ( Plib::systemstate.config.debug_level >= n ) \
INFO_PRINT
INFO_PRINTLN
// log only into std::cerr
#define ERROR_PRINT Clib::Logging::Message<Clib::Logging::LogSink_cerr>().message()

Expand Down
36 changes: 18 additions & 18 deletions pol-core/clib/network/wnsckt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool Socket::open( const char* ipaddr, unsigned short port )
#endif
)
{
INFO_PRINT2( "Unable to open socket in Socket::open()" );
INFO_PRINTLN( "Unable to open socket in Socket::open()" );
return false;
}

Expand Down Expand Up @@ -359,7 +359,7 @@ void Socket::HandleError()
{
sprintf( ErrorBuffer, "Unknown error code 0x%08x", ErrVal );
}
INFO_PRINT2( std::string( ErrorBuffer ) );
INFO_PRINTLN( std::string( ErrorBuffer ) );
#endif
#else
close();
Expand All @@ -372,7 +372,7 @@ bool Socket::recvbyte( unsigned char* ch, unsigned int waitms )
return false;

#if SCK_WATCH
INFO_PRINT2( "{L;1}" );
INFO_PRINTLN( "{L;1}" );
#endif

int res;
Expand All @@ -386,7 +386,7 @@ bool Socket::recvbyte( unsigned char* ch, unsigned int waitms )
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{TO}" );
INFO_PRINTLN( "{TO}" );
#endif
}

Expand All @@ -398,14 +398,14 @@ bool Socket::recvbyte( unsigned char* ch, unsigned int waitms )
if ( res == 1 )
{
#if SCK_WATCH
INFO_PRINT2( "{{{:#X}}}", *ch );
INFO_PRINTLN( "{{{:#X}}}", *ch );
#endif
return true;
}
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{CLOSE}" );
INFO_PRINTLN( "{CLOSE}" );
#endif
close();
return false;
Expand All @@ -427,7 +427,7 @@ bool Socket::recvdata_nowait( char* pdest, unsigned len, int* bytes_read )
return false;

#if SCK_WATCH
INFO_PRINT2( "{{L:{}}}", len );
INFO_PRINTLN( "{{L:{}}}", len );
#endif

int res;
Expand All @@ -446,7 +446,7 @@ bool Socket::recvdata_nowait( char* pdest, unsigned len, int* bytes_read )
if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{CLOSE}" );
INFO_PRINTLN( "{CLOSE}" );
#endif
close();
return false;
Expand All @@ -465,7 +465,7 @@ bool Socket::recvdata( void* vdest, unsigned len, unsigned int waitms )
return false;

#if SCK_WATCH
INFO_PRINT2( "{{L:{}}}", len );
INFO_PRINTLN( "{{L:{}}}", len );
#endif
int res;
if ( !has_incoming_data( waitms, &res ) )
Expand All @@ -478,7 +478,7 @@ bool Socket::recvdata( void* vdest, unsigned len, unsigned int waitms )
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{TO}" );
INFO_PRINTLN( "{TO}" );
#endif
}

Expand All @@ -491,20 +491,20 @@ bool Socket::recvdata( void* vdest, unsigned len, unsigned int waitms )
{
#if SCK_WATCH
char* tmp = pdest;
INFO_PRINT2( "{{R:{}[{}]}}", res, len );
INFO_PRINTLN( "{{R:{}[{}]}}", res, len );
#endif
len -= res;
pdest += res;

#if SCK_WATCH
while ( res-- )
INFO_PRINT2( "{{{:#X}}}", (unsigned char)( *tmp++ ) );
INFO_PRINTLN( "{{{:#X}}}", (unsigned char)( *tmp++ ) );
#endif
}
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{CLOSE}" );
INFO_PRINTLN( "{CLOSE}" );
#endif
close();
return false;
Expand All @@ -525,7 +525,7 @@ unsigned Socket::peek( void* vdest, unsigned len, unsigned int wait_sec )
char* pdest = (char*)vdest;

#if SCK_WATCH
INFO_PRINT2( "{{L:{}}}", len );
INFO_PRINTLN( "{{L:{}}}", len );
#endif

int res;
Expand All @@ -539,7 +539,7 @@ unsigned Socket::peek( void* vdest, unsigned len, unsigned int wait_sec )
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{TO}" );
INFO_PRINTLN( "{TO}" );
#endif
}

Expand All @@ -555,7 +555,7 @@ unsigned Socket::peek( void* vdest, unsigned len, unsigned int wait_sec )
else if ( res == 0 )
{
#if SCK_WATCH
INFO_PRINT2( "{CLOSE}" );
INFO_PRINTLN( "{CLOSE}" );
#endif
close();
return 0;
Expand Down Expand Up @@ -585,7 +585,7 @@ void Socket::send( const void* vdata, unsigned datalen )
}
else
{
INFO_PRINT2( "Socket::send() error: {}", sckerr );
INFO_PRINTLN( "Socket::send() error: {}", sckerr );
HandleError();
return;
}
Expand Down Expand Up @@ -617,7 +617,7 @@ bool Socket::send_nowait( const void* vdata, unsigned datalen, unsigned* nsent )
}
else
{
INFO_PRINT2( "Socket::send_nowait() error: {}", sckerr );
INFO_PRINTLN( "Socket::send_nowait() error: {}", sckerr );
HandleError();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion pol-core/clib/opnew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void PrintHeapData()
last_blocks_allocated = blocks_allocated;

#ifndef MEMORYLEAK
INFO_PRINT2( "OpNewHeap: allocated {} blocks, {} bytes\nOpNewHeap: delta {} blocks, {} bytes",
INFO_PRINTLN( "OpNewHeap: allocated {} blocks, {} bytes\nOpNewHeap: delta {} blocks, {} bytes",
blocks_allocated, bytes_allocated, delta_blocks, delta_bytes );
#else
DEBUGLOG << "Heap (whole): " << blocks_allocated << " blocks with " << bytes_allocated
Expand Down
2 changes: 1 addition & 1 deletion pol-core/clib/strexcpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void se_trans_func( unsigned int n, EXCEPTION_POINTERS* ex )
static bool in_ex_handler = false;
void alt_se_trans_func( unsigned int u, _EXCEPTION_POINTERS* pExp )
{
INFO_PRINT2( "In trans_func." );
INFO_PRINTLN( "In trans_func." );
if ( in_ex_handler )
{
POLLOG_INFO << "recursive structured exception\n";
Expand Down
2 changes: 1 addition & 1 deletion pol-core/clib/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Tools
{
void DebugT::print( const std::string& name, long long time )
{
INFO_PRINT2(
INFO_PRINTLN(
"\n----------------------------------\n"
"{}: {} ms"
"\n----------------------------------",
Expand Down

0 comments on commit 9bc6e30

Please sign in to comment.