mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
refactor: make spdlog optional
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
eff450c5ef
commit
b8e212d728
@@ -4,10 +4,12 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/logging.h
|
||||
)
|
||||
add_subdirectories()
|
||||
if(DEFINED NEO_SPDLOG_DIR)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/logging.h
|
||||
)
|
||||
add_subdirectories()
|
||||
endif()
|
||||
|
||||
@@ -9,12 +9,31 @@
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
|
||||
#include "driver_version.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#define QTR(a) #a
|
||||
#define TOSTR(b) QTR(b)
|
||||
#define LOG_INFO_VERSION_SHA(logType, version, sha) \
|
||||
auto logger = NEO::LogManager::getInstance()->getLogger(logType); \
|
||||
if (logger) { \
|
||||
char logBuffer[256]; \
|
||||
snprintf(logBuffer, 256, "Level zero driver version and SHA : %s - %s\n", version, sha); \
|
||||
logger->logInfo(logBuffer); \
|
||||
}
|
||||
|
||||
namespace NEO {
|
||||
std::unique_ptr<LogManager> LogManager::instancePtr = nullptr;
|
||||
uint32_t LogManager::logLevel = UINT32_MAX;
|
||||
|
||||
void initLogger() {
|
||||
if (NEO::LogManager::getLoggingLevel() != (uint32_t)NEO::LogLevel::logLevelOff) {
|
||||
CREATE_LOGGER(NEO::LogManager::LogType::coreLogger, "coreLogger.log", NEO::LogManager::getLoggingLevel());
|
||||
LOG_INFO_VERSION_SHA(NEO::LogManager::LogType::coreLogger, TOSTR(NEO_OCL_DRIVER_VERSION), NEO_REVISION);
|
||||
}
|
||||
}
|
||||
|
||||
LogManager *LogManager::getInstance() {
|
||||
if (instancePtr == nullptr) {
|
||||
LogManager::instancePtr = std::make_unique<LinuxLogManager>();
|
||||
|
||||
@@ -68,4 +68,5 @@ class LogManager {
|
||||
} \
|
||||
}
|
||||
|
||||
extern void initLogger();
|
||||
} // namespace NEO
|
||||
|
||||
@@ -37,4 +37,6 @@ uint32_t LogManager::getLoggingLevel() {
|
||||
void WinLogManager::destroyLogger(LogManager::LogType logType) {
|
||||
}
|
||||
|
||||
void initLogger(){};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(NOT DEFINED NEO_SPDLOG_DIR)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/log_manager_stub.cpp
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace NEO {
|
||||
|
||||
#define CREATE_LOGGER(...)
|
||||
|
||||
#define LOG_CRITICAL(...)
|
||||
#define LOG_CRITICAL_FOR_CORE(...)
|
||||
|
||||
#define LOG_INFO(...)
|
||||
|
||||
extern void initLogger();
|
||||
|
||||
} // namespace NEO
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
namespace NEO {
|
||||
|
||||
void initLogger(){};
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user