зеркало из https://github.com/Azure/c-logging.git
2 preprocessors (#16)
* 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:
Родитель
f7e5c0f9f7
Коммит
5d78e309a8
|
@ -86,8 +86,8 @@ if(${logerror_captures_stack_traces})
|
||||||
set(LOGGING_STACKTRACE_C_FILE ./src/logging_stacktrace.c)
|
set(LOGGING_STACKTRACE_C_FILE ./src/logging_stacktrace.c)
|
||||||
set(LOGGING_STACKTRACE_H_FILE ./inc/azure_c_logging/logging_stacktrace.h)
|
set(LOGGING_STACKTRACE_H_FILE ./inc/azure_c_logging/logging_stacktrace.h)
|
||||||
else()
|
else()
|
||||||
set(LOGGING_STACKTRACE_C_FILE)
|
set(LOGGING_STACKTRACE_C_FILE ./src/logging_stacktrace_dummy.c)
|
||||||
set(LOGGING_STACKTRACE_H_FILE)
|
set(LOGGING_STACKTRACE_H_FILE ./inc/azure_c_logging/logging_stacktrace.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${no_logging})
|
if(${no_logging})
|
||||||
|
|
|
@ -62,10 +62,10 @@ jobs:
|
||||||
displayName: 'Use NuGet 4.3.0 (required for .NET core assemblies)'
|
displayName: 'Use NuGet 4.3.0 (required for .NET core assemblies)'
|
||||||
|
|
||||||
- task: CMake@1
|
- 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:
|
inputs:
|
||||||
workingDirectory: 'build_x64'
|
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
|
- task: VSBuild@1
|
||||||
displayName: 'Build solution build_x64\*.sln'
|
displayName: 'Build solution build_x64\*.sln'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e445e1175e53734a3334dd459e283a8d0a378b4f
|
Subproject commit 4e903337052dd19275da3832453bed0e2a783563
|
|
@ -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, ...) \
|
#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(); \
|
LOGGER_LOG logger_function = xlogging_get_log_function(); \
|
||||||
if (logger_function != NULL) \
|
if (logger_function != NULL) \
|
||||||
{ \
|
{ \
|
||||||
char stackAsString[STACK_MAX_CHARACTERS]; \
|
char stackAsString[STACK_MAX_CHARACTERS]; \
|
||||||
getStackAsString(stackAsString, sizeof(STACK_MAX_CHARACTERS)); \
|
getStackAsString(stackAsString, sizeof(stackAsString)); \
|
||||||
size_t formatSize = strlen(format); \
|
size_t formatSize = strlen(format); \
|
||||||
if (formatSize + sizeof(STACK_PRINT_FORMAT) + 1 > FORMAT_MAX_CHARACTERS) \
|
if (formatSize + sizeof(STACK_PRINT_FORMAT) + 1 > FORMAT_MAX_CHARACTERS) \
|
||||||
{ /*skipping stack printing*/ \
|
{ /*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 \
|
else \
|
||||||
{ \
|
{ \
|
||||||
char formatWithStack[FORMAT_MAX_CHARACTERS]; \
|
char formatWithStack[FORMAT_MAX_CHARACTERS]; \
|
||||||
(void)memcpy(formatWithStack, format, formatSize); \
|
(void)memcpy(formatWithStack, format, formatSize); \
|
||||||
(void)memcpy(formatWithStack + formatSize, STACK_PRINT_FORMAT, sizeof(STACK_PRINT_FORMAT)); \
|
(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, ...) \
|
#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(); \
|
LOGGER_LOG logger_function = xlogging_get_log_function(); \
|
||||||
if (logger_function != NULL) \
|
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.
|
#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 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})
|
if(${run_unittests})
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
set(exeName "min_nolog_${no_logging_value}_stk_${logerror_captures_stack_traces_value}_etw_${use_etw_value}")
|
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})
|
if(${no_logging_value})
|
||||||
add_definitions(-DNO_LOGGING)
|
add_definitions(-DNO_LOGGING)
|
||||||
endif()
|
endif()
|
||||||
|
@ -10,34 +16,34 @@ endif()
|
||||||
if(${logerror_captures_stack_traces_value})
|
if(${logerror_captures_stack_traces_value})
|
||||||
#set a preprocessor option (LOGERROR_CAPTURES_STACK_TRACES) and add the files that provide the functionality
|
#set a preprocessor option (LOGERROR_CAPTURES_STACK_TRACES) and add the files that provide the functionality
|
||||||
add_definitions(-DLOGERROR_CAPTURES_STACK_TRACES)
|
add_definitions(-DLOGERROR_CAPTURES_STACK_TRACES)
|
||||||
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace.c)
|
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace.c)
|
||||||
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
|
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
|
||||||
else()
|
else()
|
||||||
set(LOGGING_STACKTRACE_C_FILE)
|
set(LOGGING_STACKTRACE_C_FILE ../../../src/logging_stacktrace_dummy.c)
|
||||||
set(LOGGING_STACKTRACE_H_FILE)
|
set(LOGGING_STACKTRACE_H_FILE ../../../inc/azure_c_logging/logging_stacktrace.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${use_etw} STREQUAL "TRACELOGGING")
|
if (${use_etw_value} STREQUAL "TRACELOGGING")
|
||||||
add_definitions(-DUSE_TRACELOGGING)
|
add_definitions(-DUSE_TRACELOGGING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${use_etw} STREQUAL "TRACELOGGING_WITH_CONSOLE")
|
if (${use_etw_value} STREQUAL "TRACELOGGING_WITH_CONSOLE")
|
||||||
add_definitions(-DUSE_TRACELOGGING)
|
add_definitions(-DUSE_TRACELOGGING)
|
||||||
add_definitions(-DCALL_CONSOLE_LOGGER)
|
add_definitions(-DCALL_CONSOLE_LOGGER)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${use_etw} STREQUAL "OFF")
|
if(${use_etw_value} STREQUAL "OFF")
|
||||||
set(XLOGGING_C_FILE ../../../src/xlogging.c PARENT_SCOPE)
|
set(XLOGGING_C_FILE ../../../src/xlogging.c)
|
||||||
set(LOGGING_C_FILE ../../../src/consolelogger.c PARENT_SCOPE)
|
set(LOGGING_C_FILE ../../../src/consolelogger.c)
|
||||||
set(LOGGING_H_FILE ../../../inc/azure_c_logging/consolelogger.h PARENT_SCOPE)
|
set(LOGGING_H_FILE ../../../inc/azure_c_logging/consolelogger.h)
|
||||||
elseif(${use_etw} STREQUAL "TRACELOGGING")
|
elseif(${use_etw_value} STREQUAL "TRACELOGGING")
|
||||||
set(XLOGGING_C_FILE ../../../src/etwxlogging.c PARENT_SCOPE)
|
set(XLOGGING_C_FILE ../../../src/etwxlogging.c)
|
||||||
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c PARENT_SCOPE)
|
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c)
|
||||||
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h PARENT_SCOPE)
|
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h)
|
||||||
elseif(${use_etw} STREQUAL "TRACELOGGING_WITH_CONSOLE")
|
elseif(${use_etw_value} STREQUAL "TRACELOGGING_WITH_CONSOLE")
|
||||||
set(XLOGGING_C_FILE ../../../src/etwxlogging.c PARENT_SCOPE)
|
set(XLOGGING_C_FILE ../../../src/etwxlogging.c)
|
||||||
set(LOGGING_C_FILE ../../../src/etwlogger_driver.c ../../../src/consolelogger.c PARENT_SCOPE)
|
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 PARENT_SCOPE)
|
set(LOGGING_H_FILE ../../../inc/azure_c_logging/etwlogger_driver.h ../../../inc/azure_c_logging/consolelogger.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalOptions>/FI "vld.h"</AdditionalOptions>
|
<AdditionalOptions>%(AdditionalOptions) /FI "vld.h"</AdditionalOptions>
|
||||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);"c:\Program Files (x86)\Visual Leak Detector\include"</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);"c:\Program Files (x86)\Visual Leak Detector\include"</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link Condition="'$(Platform)' == 'x86'">
|
<Link Condition="'$(Platform)' == 'x86'">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче