* changes to logging

* adjust captured stack

* use latest

* removed extraneous comma

* removed extraneous message status

* do not overwrite existing additional options
This commit is contained in:
anporumb 2020-10-05 16:04:10 -07:00 коммит произвёл GitHub
Родитель f7e5c0f9f7
Коммит 5d78e309a8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 58 добавлений и 34 удалений

Просмотреть файл

@ -86,8 +86,8 @@ if(${logerror_captures_stack_traces})
set(LOGGING_STACKTRACE_C_FILE ./src/logging_stacktrace.c)
set(LOGGING_STACKTRACE_H_FILE ./inc/azure_c_logging/logging_stacktrace.h)
else()
set(LOGGING_STACKTRACE_C_FILE)
set(LOGGING_STACKTRACE_H_FILE)
set(LOGGING_STACKTRACE_C_FILE ./src/logging_stacktrace_dummy.c)
set(LOGGING_STACKTRACE_H_FILE ./inc/azure_c_logging/logging_stacktrace.h)
endif()
if(${no_logging})

Просмотреть файл

@ -62,10 +62,10 @@ jobs:
displayName: 'Use NuGet 4.3.0 (required for .NET core assemblies)'
- task: CMake@1
displayName: 'CMake .. -Drun_unittests:bool=ON -Drun_int_tests:bool=ON -Duse_cppunittest:bool=OFF -G "Visual Studio 16 2019" -A x64"'
displayName: 'CMake .. -Drun_unittests:bool=ON -Drun_int_tests:bool=ON -Duse_cppunittest:bool=OFF -G "Visual Studio 16 2019" -A x64'
inputs:
workingDirectory: 'build_x64'
cmakeArgs: '.. -Drun_unittests:bool=ON -Drun_int_tests:bool=ON -Duse_cppunittest:bool=OFF -G "Visual Studio 16 2019" -A x64"'
cmakeArgs: '.. -Drun_unittests:bool=ON -Drun_int_tests:bool=ON -Duse_cppunittest:bool=OFF -G "Visual Studio 16 2019" -A x64'
- task: VSBuild@1
displayName: 'Build solution build_x64\*.sln'

2
deps/azure-c-build-tools поставляемый

@ -1 +1 @@
Subproject commit e445e1175e53734a3334dd459e283a8d0a378b4f
Subproject commit 4e903337052dd19275da3832453bed0e2a783563

2
deps/azure-macro-utils-c поставляемый

@ -1 +1 @@
Subproject commit a4dec7c164c201ce821ba984991e210f4c721437
Subproject commit 4cbcec60757b904e47bff4aa5a2e5addae5bcf57

Просмотреть файл

@ -89,24 +89,24 @@ typedef void(*LOGGER_LOG_GETLASTERROR)(const char* file, const char* func, int l
#define LOG_AZ_LOG_WITH_STACK(log_category, log_options, format, ...) \
{ \
(void)(0 && printf(format, ##__VA_ARGS__)); \
(void)(0 && printf(format, ##__VA_ARGS__)); \
{ \
LOGGER_LOG logger_function = xlogging_get_log_function(); \
if (logger_function != NULL) \
{ \
char stackAsString[STACK_MAX_CHARACTERS]; \
getStackAsString(stackAsString, sizeof(STACK_MAX_CHARACTERS)); \
getStackAsString(stackAsString, sizeof(stackAsString)); \
size_t formatSize = strlen(format); \
if (formatSize + sizeof(STACK_PRINT_FORMAT) + 1 > FORMAT_MAX_CHARACTERS) \
{ /*skipping stack printing*/ \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, format, ##__VA_ARGS__); \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, format, ##__VA_ARGS__); \
} \
else \
{ \
char formatWithStack[FORMAT_MAX_CHARACTERS]; \
(void)memcpy(formatWithStack, format, formatSize); \
(void)memcpy(formatWithStack + formatSize, STACK_PRINT_FORMAT, sizeof(STACK_PRINT_FORMAT)); \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, formatWithStack, ##__VA_ARGS__, stackAsString); \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, formatWithStack, ##__VA_ARGS__, stackAsString); \
} \
} \
} \
@ -114,12 +114,12 @@ typedef void(*LOGGER_LOG_GETLASTERROR)(const char* file, const char* func, int l
#define LOG_AZ_LOG_WITHOUT_STACK(log_category, log_options, format, ...) \
{ \
(void)(0 && printf(format, ##__VA_ARGS__)); \
(void)(0 && printf(format, ##__VA_ARGS__)); \
{ \
LOGGER_LOG logger_function = xlogging_get_log_function(); \
if (logger_function != NULL) \
LOGGER_LOG logger_function = xlogging_get_log_function(); \
if (logger_function != NULL) \
{ \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, format, ##__VA_ARGS__); \
logger_function(log_category, __FILE__, FUNC_NAME, __LINE__, log_options, format, ##__VA_ARGS__); \
} \
} \
}

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stddef.h>
#include <stdio.h>
#include "azure_c_logging/logging_stacktrace.h"
static const char message[] = "stack capture disabled";
void getStackAsString(char* destination, size_t size)
{
if (destination != NULL)
{
/*make a best effort at trying to provide some message*/
(void)snprintf(destination, size, "%s", message);
}
}

Просмотреть файл

@ -2,7 +2,7 @@
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#the purpose of these tests is to see that a LogError/LogInfo/LogLastError would compile under all switch combinations
#the tests will not recompile the complete c_util library, only the relevant parts. These tests only target Windows
#the tests will not recompile the complete c_logging library, only the relevant parts. These tests only target Windows
if(${run_unittests})

Просмотреть файл

@ -3,6 +3,12 @@
set(exeName "min_nolog_${no_logging_value}_stk_${logerror_captures_stack_traces_value}_etw_${use_etw_value}")
#this environment must not inherit previous definitions. So try remove them (if existing)
remove_definitions(-DNO_LOGGING)
remove_definitions(-DLOGERROR_CAPTURES_STACK_TRACES)
remove_definitions(-DUSE_TRACELOGGING)
remove_definitions(-DCALL_CONSOLE_LOGGER)
if(${no_logging_value})
add_definitions(-DNO_LOGGING)
endif()
@ -10,34 +16,34 @@ endif()
if(${logerror_captures_stack_traces_value})
#set a preprocessor option (LOGERROR_CAPTURES_STACK_TRACES) and add the files that provide the functionality
add_definitions(-DLOGERROR_CAPTURES_STACK_TRACES)
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace.c)
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace.c)
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
else()
set(LOGGING_STACKTRACE_C_FILE)
set(LOGGING_STACKTRACE_H_FILE)
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace_dummy.c)
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
endif()
if (${use_etw} STREQUAL "TRACELOGGING")
if (${use_etw_value} STREQUAL "TRACELOGGING")
add_definitions(-DUSE_TRACELOGGING)
endif()
if (${use_etw} STREQUAL "TRACELOGGING_WITH_CONSOLE")
if (${use_etw_value} STREQUAL "TRACELOGGING_WITH_CONSOLE")
add_definitions(-DUSE_TRACELOGGING)
add_definitions(-DCALL_CONSOLE_LOGGER)
endif()
if(${use_etw} STREQUAL "OFF")
set(XLOGGING_C_FILE ../../../src/xlogging.c PARENT_SCOPE)
set(LOGGING_C_FILE ../../../src/consolelogger.c PARENT_SCOPE)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/consolelogger.h PARENT_SCOPE)
elseif(${use_etw} STREQUAL "TRACELOGGING")
set(XLOGGING_C_FILE ../../../src/etwxlogging.c PARENT_SCOPE)
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c PARENT_SCOPE)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h PARENT_SCOPE)
elseif(${use_etw} STREQUAL "TRACELOGGING_WITH_CONSOLE")
set(XLOGGING_C_FILE ../../../src/etwxlogging.c PARENT_SCOPE)
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c ../../../src/consolelogger.c PARENT_SCOPE)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h ../../../inc/azure_c_logging/consolelogger.h PARENT_SCOPE)
if(${use_etw_value} STREQUAL "OFF")
set(XLOGGING_C_FILE ../../../src/xlogging.c)
set(LOGGING_C_FILE ../../../src/consolelogger.c)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/consolelogger.h)
elseif(${use_etw_value} STREQUAL "TRACELOGGING")
set(XLOGGING_C_FILE ../../../src/etwxlogging.c)
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h)
elseif(${use_etw_value} STREQUAL "TRACELOGGING_WITH_CONSOLE")
set(XLOGGING_C_FILE ../../../src/etwxlogging.c)
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c ../../../src/consolelogger.c)
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h ../../../inc/azure_c_logging/consolelogger.h)
endif()

Просмотреть файл

@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/FI "vld.h"</AdditionalOptions>
<AdditionalOptions>%(AdditionalOptions) /FI "vld.h"</AdditionalOptions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);"c:\Program Files (x86)\Visual Leak Detector\include"</AdditionalIncludeDirectories>
</ClCompile>
<Link Condition="'$(Platform)' == 'x86'">