Skip to content

Commit

Permalink
fix loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
irov committed Jul 31, 2023
1 parent d50ba2a commit 7ac06d6
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 58 deletions.
4 changes: 2 additions & 2 deletions gradle/split.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
defaultConfig {
if (ANDROID_APP_SPLIT_ENABLE == false) {
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86"
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
}
}
}
Expand All @@ -17,7 +17,7 @@ android {

reset() //reset the list of ABIs to be included to an empty string

include "arm64-v8a", "armeabi-v7a", "x86_64", "x86"
include "arm64-v8a", "armeabi-v7a", "x86", "x86_64"

universalApk false
}
Expand Down
36 changes: 19 additions & 17 deletions src/Environment/Android/AndroidLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace Mengine
break;
}

Char message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};

if( _message.flag & ELoggerFlag::LFLAG_FUNCTIONSTAMP )
{
Char functionstamp[MENGINE_MAX_PATH] = {'\0'};
Expand All @@ -62,8 +64,8 @@ namespace Mengine
int32_t line = _message.line;
size_t functionstampSize = Helper::makeLoggerFunctionStamp( file, line, "%s[%d]", functionstamp, 0, MENGINE_MAX_PATH );

MENGINE_STRCAT( m_message, functionstamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, functionstamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_TIMESTAMP )
Expand All @@ -73,70 +75,70 @@ namespace Mengine
const PlatformDateTime & dateTime = _message.dateTime;
size_t timestampSize = Helper::makeLoggerTimeStamp( dateTime, "[%02u:%02u:%02u:%04u]", timestamp, 0, 256 );

MENGINE_STRCAT( m_message, timestamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, timestamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_THREADSTAMP )
{
Char threadstamp[256] = {'\0'};
size_t threadstampSize = Helper::makeLoggerThreadStamp( "|%s|", threadstamp, 0, 256 );

MENGINE_STRCAT( m_message, threadstamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, threadstamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_CATEGORYSTAMP )
{
const Char * category = _message.category;

MENGINE_STRCAT( m_message, "[" );
MENGINE_STRCAT( m_message, category );
MENGINE_STRCAT( m_message, "]" );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, "[" );
MENGINE_STRCAT( message, category );
MENGINE_STRCAT( message, "]" );
MENGINE_STRCAT( message, " " );
}

const Char * data = _message.data;
size_t size = _message.size;

size_t message_stamplen = MENGINE_STRLEN( m_message );
size_t message_stamplen = MENGINE_STRLEN( message );

if( size + message_stamplen >= MENGINE_LOGGER_MAX_MESSAGE )
{
size = MENGINE_LOGGER_MAX_MESSAGE - message_stamplen - 1;
}

MENGINE_STRNCAT( m_message, data, size );
MENGINE_STRNCAT( message, data, size );

size_t message_len = MENGINE_STRLEN( m_message );
size_t message_len = MENGINE_STRLEN( message );

size_t message_packages = message_len / MENGINE_ANDROID_LOG_MAX_MESSAGE;
size_t message_tail = message_len % MENGINE_ANDROID_LOG_MAX_MESSAGE;

if( message_packages != 0 )
{
__android_log_print( prio, "Mengine", "%.*s <<<"
, (int32_t)MENGINE_ANDROID_LOG_MAX_MESSAGE, m_message
, (int32_t)MENGINE_ANDROID_LOG_MAX_MESSAGE, message
);

for( size_t package = 1; package != message_packages; ++package )
{
__android_log_print( prio, "Mengine", ">>> %.*s"
, (int32_t)MENGINE_ANDROID_LOG_MAX_MESSAGE, m_message + package * MENGINE_ANDROID_LOG_MAX_MESSAGE
, (int32_t)MENGINE_ANDROID_LOG_MAX_MESSAGE, message + package * MENGINE_ANDROID_LOG_MAX_MESSAGE
);
}

if( message_tail != 0 )
{
__android_log_print( prio, "Mengine", ">>> %s"
, m_message + message_packages * MENGINE_ANDROID_LOG_MAX_MESSAGE
, message + message_packages * MENGINE_ANDROID_LOG_MAX_MESSAGE
);
}
}
else
{
__android_log_print( prio, "Mengine", "%s"
, m_message + message_packages * MENGINE_ANDROID_LOG_MAX_MESSAGE
, message + message_packages * MENGINE_ANDROID_LOG_MAX_MESSAGE
);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/Environment/Android/AndroidLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ namespace Mengine

public:
void _log( const LoggerMessage & _message ) override;

protected:
Char m_message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};
};
}
3 changes: 0 additions & 3 deletions src/Environment/Apple/AppleNSLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ namespace Mengine

public:
void _log( const LoggerMessage & _message ) override;

protected:
Char m_message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};
};
//////////////////////////////////////////////////////////////////////////
typedef IntrusivePtr<AppleNSLogger, LoggerInterface> AppleNSLoggerPtr;
Expand Down
40 changes: 20 additions & 20 deletions src/Environment/Apple/AppleNSLogger.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//////////////////////////////////////////////////////////////////////////
void AppleNSLogger::_log( const LoggerMessage & _message )
{
MENGINE_STRCPY( m_message, "" );
Char message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};

if( _message.flag & ELoggerFlag::LFLAG_FUNCTIONSTAMP )
{
Expand All @@ -31,8 +31,8 @@
int32_t line = _message.line;
size_t functionstampSize = Helper::makeLoggerFunctionStamp( file, line, "%s[%d]", functionstamp, 0, MENGINE_MAX_PATH );

MENGINE_STRCAT( m_message, functionstamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, functionstamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_TIMESTAMP )
Expand All @@ -42,17 +42,17 @@
const PlatformDateTime & dateTime = _message.dateTime;
size_t timestampSize = Helper::makeLoggerTimeStamp( dateTime, "[%02u:%02u:%02u:%04u]", timestamp, 0, 256 );

MENGINE_STRCAT( m_message, timestamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, timestamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_THREADSTAMP )
{
Char threadstamp[256] = {'\0'};
size_t threadstampSize = Helper::makeLoggerThreadStamp( "|%s|", threadstamp, 0, 256 );

MENGINE_STRCAT( m_message, threadstamp );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, threadstamp );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_SYMBOLSTAMP )
Expand All @@ -61,54 +61,54 @@

Char symbol = Helper::getLoggerLevelSymbol( level );

MENGINE_STRNCAT( m_message, &symbol, 1 );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRNCAT( message, &symbol, 1 );
MENGINE_STRCAT( message, " " );
}

if( _message.flag & LFLAG_CATEGORYSTAMP )
{
const Char * category = _message.category;

MENGINE_STRCAT( m_message, "[" );
MENGINE_STRCAT( m_message, category );
MENGINE_STRCAT( m_message, "]" );
MENGINE_STRCAT( m_message, " " );
MENGINE_STRCAT( message, "[" );
MENGINE_STRCAT( message, category );
MENGINE_STRCAT( message, "]" );
MENGINE_STRCAT( message, " " );
}

const Char * data = _message.data;
size_t size = _message.size;

size_t message_stamplen = MENGINE_STRLEN( m_message );
size_t message_stamplen = MENGINE_STRLEN( message );

if( size + message_stamplen >= MENGINE_LOGGER_MAX_MESSAGE )
{
size = MENGINE_LOGGER_MAX_MESSAGE - message_stamplen - 1;
}

MENGINE_STRNCAT( m_message, data, size );
MENGINE_STRNCAT( message, data, size );

size_t message_len = MENGINE_STRLEN( m_message );
size_t message_len = MENGINE_STRLEN( message );

size_t message_packages = message_len / MENGINE_APPLE_LOG_MAX_MESSAGE;
size_t message_tail = message_len % MENGINE_APPLE_LOG_MAX_MESSAGE;

if( message_packages != 0 )
{
NSLog( @"%.*s <<<", MENGINE_APPLE_LOG_MAX_MESSAGE, m_message );
NSLog( @"%.*s <<<", MENGINE_APPLE_LOG_MAX_MESSAGE, message );

for( size_t package = 1; package != message_packages; ++package )
{
NSLog( @">>> %.*s", MENGINE_APPLE_LOG_MAX_MESSAGE, m_message + package * MENGINE_APPLE_LOG_MAX_MESSAGE );
NSLog( @">>> %.*s", MENGINE_APPLE_LOG_MAX_MESSAGE, message + package * MENGINE_APPLE_LOG_MAX_MESSAGE );
}

if( message_tail != 0 )
{
NSLog( @">>> %s", m_message + message_packages * MENGINE_APPLE_LOG_MAX_MESSAGE );
NSLog( @">>> %s", message + message_packages * MENGINE_APPLE_LOG_MAX_MESSAGE );
}
}
else
{
NSLog( @"%s", m_message + message_packages * MENGINE_APPLE_LOG_MAX_MESSAGE );
NSLog( @"%s", message + message_packages * MENGINE_APPLE_LOG_MAX_MESSAGE );
}
}
//////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/Environment/Windows/Win32MessageBoxLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Mengine
Char message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};
MENGINE_SNPRINTF( message, MENGINE_LOGGER_MAX_MESSAGE, "%.*s"
, size
, data
, data
);

Helper::debuggerBreak();
Expand Down
18 changes: 9 additions & 9 deletions src/Plugins/Win32SentryPlugin/Win32SentryLoggerCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ namespace Mengine
return;
}

MENGINE_STRCPY( m_message, "" );
Char message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};

Char timestamp[256] = {'\0'};
size_t timestampSize = Helper::makeLoggerTimeStamp( _message.dateTime, "[%02u:%02u:%02u:%04u]", timestamp, 0, 256 );
MENGINE_STRNCAT( m_message, timestamp, timestampSize );
MENGINE_STRNCAT( m_message, " ", 1 );
MENGINE_STRNCAT( message, timestamp, timestampSize );
MENGINE_STRCAT( message, " " );

MENGINE_STRNCAT( m_message, "[", 1 );
MENGINE_STRCAT( m_message, _message.category );
MENGINE_STRNCAT( m_message, "]", 1 );
MENGINE_STRNCAT( m_message, " ", 1 );
MENGINE_STRCAT( message, "[" );
MENGINE_STRCAT( message, _message.category );
MENGINE_STRCAT( message, "]" );
MENGINE_STRCAT( message, " " );

const Char * data_str = _message.data;
size_t data_size = _message.size;

MENGINE_STRNCAT( m_message, data_str, data_size );
MENGINE_STRNCAT( message, data_str, data_size );

sentry_value_t event = sentry_value_new_message_event( sentry_level, "Logger", m_message );
sentry_value_t event = sentry_value_new_message_event( sentry_level, "Logger", message );

sentry_capture_event( event );
}
Expand Down
3 changes: 0 additions & 3 deletions src/Plugins/Win32SentryPlugin/Win32SentryLoggerCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace Mengine

protected:
void _log( const LoggerMessage & _message ) override;

protected:
Char m_message[MENGINE_LOGGER_MAX_MESSAGE] = {'\0'};
};
//////////////////////////////////////////////////////////////////////////
typedef IntrusivePtr<Win32SentryLoggerCapture, LoggerInterface> Win32SentryLoggerCapturePtr;
Expand Down

0 comments on commit 7ac06d6

Please sign in to comment.