!40852 adapt ms.log to windows

Merge pull request !40852 from chenminmin/master
This commit is contained in:
i-robot 2022-08-29 01:14:55 +00:00 committed by Gitee
commit 1483877469
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
21 changed files with 104 additions and 94 deletions

View File

@ -1053,7 +1053,7 @@ std::vector<CNodePtr> KernelGraph::FindNodeByPrimitive(const std::vector<Primiti
}
void KernelGraph::PrintGraphExecuteOrder() const {
if (!(IS_OUTPUT_ON(INFO))) {
if (!(IS_OUTPUT_ON(mindspore::kInfo))) {
return;
}
MS_LOG(INFO) << "Graph " << graph_id_ << " execution order:";

View File

@ -613,7 +613,7 @@ void DebugServices::CheckWatchpoints(std::vector<std::string> *const name, std::
if (tensor_list_size == 0) {
return;
}
if (IS_OUTPUT_ON(INFO)) {
if (IS_OUTPUT_ON(mindspore::kInfo)) {
wp_progress_enabled_ = true;
wp_progress_thread_ =
std::make_unique<std::thread>([this, tensor_list_size]() { CheckWatchpointProgress(tensor_list_size); });
@ -668,7 +668,7 @@ void DebugServices::CheckWatchpoints(std::vector<std::string> *const name, std::
MS_LOG(INFO) << "tensor_list byte size is " << tensor_list_byte_size / pow(10.0, 6.0) << " MB";
MS_LOG(INFO) << "CheckWatchpoints Took: " << std::fixed << std::setprecision(precision)
<< (ms_double.count()) / ms_to_s << "s";
if (IS_OUTPUT_ON(INFO) && wp_progress_thread_ && wp_progress_thread_->joinable()) {
if (IS_OUTPUT_ON(mindspore::kInfo) && wp_progress_thread_ && wp_progress_thread_->joinable()) {
wp_progress_enabled_ = false;
wp_progress_thread_->join();
MS_LOG(INFO) << "Join wp_progress_thread_.";

View File

@ -106,7 +106,7 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
run_only_once_ = run_only_once;
is_watch_renormalize_ = false;
is_untyped_generated_ = false;
is_on_debug_ = IS_OUTPUT_ON(mindspore::DEBUG);
is_on_debug_ = IS_OUTPUT_ON(mindspore::kDebug);
for (auto &iter : passes) {
const std::string &name = iter.first;

View File

@ -56,7 +56,7 @@ class Ensures : public EnsuresAccess<T, R> {
if (!R::Check(value_)) {
LogStream contract_stream;
contract_stream << "contract error: " << signatory.extra_info << R::Desc();
LogWriter(signatory.location_info, EXCEPTION, SUBMODULE_ID, ArgumentError) ^ contract_stream;
LogWriter(signatory.location_info, MsLogLevel::kException, SUBMODULE_ID, ArgumentError) ^ contract_stream;
}
}
template <class O, typename = std::enable_if_t<std::is_convertible_v<O, T>>>

View File

@ -380,7 +380,7 @@ Status CacheAdminArgHandler::Validate() {
"Number of workers must be in range of 1 and " + std::to_string(max_num_workers) + ".");
}
if (log_level_ < MsLogLevel::DEBUG || log_level_ > MsLogLevel::EXCEPTION) {
if (log_level_ < MsLogLevel::kDebug || log_level_ > MsLogLevel::kException) {
return Status(StatusCode::kMDSyntaxError, "Log level must be in range (0..4).");
}

View File

@ -37,7 +37,7 @@ Status NodeOffloadPass::OffloadNodes::Visit(std::shared_ptr<MapNode> node, bool
if ((manual_offload == ManualOffloadMode::kEnabled) ||
((auto_offload_ == true) && (manual_offload != ManualOffloadMode::kDisabled))) {
bool offload_supported = true;
if (IS_OUTPUT_ON(mindspore::INFO)) {
if (IS_OUTPUT_ON(mindspore::kInfo)) {
std::string operations = "operations=[";
auto op_list = node->operations();
std::for_each(op_list.begin(), op_list.end(), [&](const auto &op) {

View File

@ -36,7 +36,7 @@ PluginLoader::~PluginLoader() {
std::transform(plugins_.begin(), plugins_.end(), std::back_inserter(keys), [](const auto &p) { return p.first; });
for (std::string &key : keys) {
Status rc = UnloadPlugin(key);
MSLOG_IF(ERROR, rc.IsError(), mindspore::NoExceptionType) << rc.ToString();
MSLOG_IF(MsLogLevel::kError, rc.IsError(), mindspore::NoExceptionType) << rc.ToString();
}
}

View File

@ -3018,7 +3018,7 @@ FunctionBlockPtr Parser::ParseWith(const FunctionBlockPtr &block, const py::obje
void Parser::PrintPhiArgMaps(const std::map<ParameterPtr, std::set<AnfNodePtr>> &phi_to_args,
const std::map<AnfNodePtr, std::set<ParameterPtr>> &arg_to_phis) {
if (!IS_OUTPUT_ON(DEBUG)) {
if (!IS_OUTPUT_ON(mindspore::kDebug)) {
return;
}
std::ostringstream oss;
@ -3136,7 +3136,7 @@ std::shared_ptr<std::map<ParameterPtr, AnfNodePtr>> Parser::CollectRemovablePhiA
(*need_remove_phi_args)[phi] = *(args.begin());
}
}
if (IS_OUTPUT_ON(DEBUG)) {
if (IS_OUTPUT_ON(mindspore::kDebug)) {
size_t m = 0;
std::ostringstream oss;
oss << "=====================Need removed phis and args====================="

View File

@ -38,7 +38,7 @@ void AnalysisSchedule::Schedule() {
MS_LOG(DEBUG) << "Success to exit.";
}
void AnalysisSchedule::Yield(AsyncInferTask *async_infer_task) {
void AnalysisSchedule::YieldTask(AsyncInferTask *async_infer_task) {
MS_EXCEPTION_IF_NULL(async_infer_task);
{
std::lock_guard<std::mutex> activeLock(activate_thread_lock_);

View File

@ -57,7 +57,7 @@ class AnalysisSchedule {
void Wait();
void Add2Schedule(const AsyncInferTaskPtr &async_infer_task_ptr);
void WaitForRun() const;
void Yield(AsyncInferTask *asyncTask);
void YieldTask(AsyncInferTask *asyncTask);
void EnterWaiting() {
{
@ -327,7 +327,7 @@ class AsyncInferTask {
AbstractBasePtr GetResult() {
StaticAnalysisException::Instance().CheckException();
AnalysisSchedule::GetInstance().Yield(this);
AnalysisSchedule::GetInstance().YieldTask(this);
std::unique_lock<std::mutex> lock(lock_);
MS_LOG(DEBUG) << AnalysisSchedule::thread_id() << " waiting.";
condition_var_.wait(lock, [this] { return ready_; });

View File

@ -70,10 +70,14 @@ void PyNativeExecutorTry(const std::function<void(T *ret, const Args &...)> &met
throw(std::runtime_error(ex.what()));
} catch (...) {
inst->ClearRes();
#ifndef _MSC_VER
auto exception_type = abi::__cxa_current_exception_type();
MS_EXCEPTION_IF_NULL(exception_type);
std::string ex_name(exception_type->name());
MS_LOG(EXCEPTION) << "Error occurred when compile graph. Exception name: " << ex_name;
#else
MS_LOG(EXCEPTION) << "Error occurred when compile graph.";
#endif
}
}
} // namespace

View File

@ -138,13 +138,13 @@ void PrintInfo(const nlohmann::json &info, const std::string &job_name, const in
auto message = GetJsonValue<std::string>(info, kMessage);
if (level == 0) {
MS_LOG(DEBUG) << "Job id:" << job_id << ", name :" << job_name << ", message:" << message;
} else if (level == static_cast<int>(INFO)) {
} else if (level == static_cast<int>(MsLogLevel::kInfo)) {
MS_LOG(INFO) << "Job id:" << job_id << ", name :" << job_name << ", message:" << message;
} else if (level == static_cast<int>(WARNING)) {
} else if (level == static_cast<int>(MsLogLevel::kWarning)) {
MS_LOG(WARNING) << "Job id:" << job_id << ", name :" << job_name << ", message:" << message;
} else if (level == static_cast<int>(ERROR)) {
} else if (level == static_cast<int>(MsLogLevel::kError)) {
MS_LOG(ERROR) << "Job id:" << job_id << ", name :" << job_name << ", message:" << message;
} else if (level == static_cast<int>(EXCEPTION)) {
} else if (level == static_cast<int>(MsLogLevel::kException)) {
ReportToErrorManager(message);
}
}
@ -238,7 +238,8 @@ std::vector<std::string> GetTuneOpsList(const std::string &d) {
}
} // namespace
void TbeKernelCompileManager::PrintProcessLog(const nlohmann::json &json, int adjust_log_level = EXCEPTION) const {
void TbeKernelCompileManager::PrintProcessLog(const nlohmann::json &json,
int adjust_log_level = MsLogLevel::kException) const {
auto all_logs = GetJsonValue<std::vector<nlohmann::json>>(json, kProcessInfo);
auto job_id = GetJsonValue<int>(json, kJobId);
auto json_name = GetJsonValue<std::string>(json, kFusionOpName);
@ -590,7 +591,7 @@ std::string TbeKernelCompileManager::ParseSelectAndCheckResult(const nlohmann::j
return kFailed;
}
if (res != kFullySupported) {
PrintProcessLog(json, static_cast<int>(DEBUG));
PrintProcessLog(json, static_cast<int>(MsLogLevel::kDebug));
}
} else if (json.at(kStatus) == kFailed) {
auto all_logs = GetJsonValue<std::vector<nlohmann::json>>(json, kProcessInfo);

View File

@ -107,7 +107,7 @@ class TrtUtils {
class TrtLogger : public nvinfer1::ILogger {
public:
TrtLogger() {
log_level_ = MsLogLevel::WARNING; // set default log level to WARNING
log_level_ = MsLogLevel::kWarning; // set default log level to WARNING
const char *glog_config = std::getenv("GLOG_v");
if (glog_config == nullptr) {
return;
@ -117,7 +117,7 @@ class TrtLogger : public nvinfer1::ILogger {
if (str_level.size() == 1) {
int ch = str_level.c_str()[0];
ch = ch - '0'; // subtract ASCII code of '0', which is 48
if (ch >= mindspore::DEBUG && ch <= mindspore::EXCEPTION) {
if (ch >= MsLogLevel::kDebug && ch <= MsLogLevel::kException) {
log_level_ = static_cast<MsLogLevel>(ch);
}
}
@ -127,11 +127,11 @@ class TrtLogger : public nvinfer1::ILogger {
#ifdef USE_GLOG
#define google mindspore_private
static std::map<Severity, std::tuple<MsLogLevel, int, std::string>> logger_map = {
{Severity::kVERBOSE, {MsLogLevel::DEBUG, google::GLOG_INFO, "VERBOSE"}},
{Severity::kINFO, {MsLogLevel::INFO, google::GLOG_INFO, "INFO"}},
{Severity::kWARNING, {MsLogLevel::WARNING, google::GLOG_WARNING, "WARNING"}},
{Severity::kERROR, {MsLogLevel::ERROR, google::GLOG_ERROR, "ERROR"}},
{Severity::kINTERNAL_ERROR, {MsLogLevel::ERROR, google::GLOG_ERROR, "INTERNAL ERROR"}}};
{Severity::kVERBOSE, {MsLogLevel::kDebug, google::GLOG_INFO, "VERBOSE"}},
{Severity::kINFO, {MsLogLevel::kInfo, google::GLOG_INFO, "INFO"}},
{Severity::kWARNING, {MsLogLevel::kWarning, google::GLOG_WARNING, "WARNING"}},
{Severity::kERROR, {MsLogLevel::kError, google::GLOG_ERROR, "ERROR"}},
{Severity::kINTERNAL_ERROR, {MsLogLevel::kError, google::GLOG_ERROR, "INTERNAL ERROR"}}};
auto iter = logger_map.find(severity);
if (iter == logger_map.end()) {

View File

@ -315,11 +315,11 @@ void TcpClient::Start() {
int ret = event_base_dispatch(event_base_);
// is_started_ should be false when finish dispatch
is_started_ = false;
MSLOG_IF(INFO, ret == 0, NoExceptionType) << "Event base dispatch success!";
MSLOG_IF(mindspore::ERROR, ret == 1, NoExceptionType)
MSLOG_IF(MsLogLevel::kInfo, ret == 0, NoExceptionType) << "Event base dispatch success!";
MSLOG_IF(MsLogLevel::kError, ret == 1, NoExceptionType)
<< "Event base dispatch failed with no events pending or active!";
MSLOG_IF(mindspore::ERROR, ret == -1, NoExceptionType) << "Event base dispatch failed with error occurred!";
MSLOG_IF(mindspore::EXCEPTION, ret < -1, AbortedError) << "Event base dispatch with unexpected error code!";
MSLOG_IF(MsLogLevel::kError, ret == -1, NoExceptionType) << "Event base dispatch failed with error occurred!";
MSLOG_IF(MsLogLevel::kException, ret < -1, AbortedError) << "Event base dispatch with unexpected error code!";
}
void TcpClient::StartWithNoBlock() {
@ -327,10 +327,10 @@ void TcpClient::StartWithNoBlock() {
MS_LOG(INFO) << "Start tcp client with no block!";
MS_EXCEPTION_IF_NULL(event_base_);
int ret = event_base_loop(event_base_, EVLOOP_NONBLOCK);
MSLOG_IF(INFO, ret == 0, NoExceptionType) << "Event base loop success!";
MSLOG_IF(mindspore::ERROR, ret == 1, NoExceptionType) << "Event base loop failed with no events pending or active!";
MSLOG_IF(mindspore::ERROR, ret == -1, NoExceptionType) << "Event base loop failed with error occurred!";
MSLOG_IF(mindspore::EXCEPTION, ret < -1, AbortedError) << "Event base loop with unexpected error code!";
MSLOG_IF(MsLogLevel::kInfo, ret == 0, NoExceptionType) << "Event base loop success!";
MSLOG_IF(MsLogLevel::kError, ret == 1, NoExceptionType) << "Event base loop failed with no events pending or active!";
MSLOG_IF(MsLogLevel::kError, ret == -1, NoExceptionType) << "Event base loop failed with error occurred!";
MSLOG_IF(MsLogLevel::kException, ret < -1, AbortedError) << "Event base loop with unexpected error code!";
}
void TcpClient::SetMessageCallback(const OnMessage &cb) { message_callback_ = cb; }

View File

@ -205,11 +205,11 @@ void TcpServer::Start() {
MS_LOG(INFO) << "Start tcp server!";
MS_EXCEPTION_IF_NULL(base_);
int ret = event_base_dispatch(base_);
MSLOG_IF(INFO, ret == 0, NoExceptionType) << "Event base dispatch success!";
MSLOG_IF(mindspore::ERROR, ret == 1, NoExceptionType)
MSLOG_IF(MsLogLevel::kInfo, ret == 0, NoExceptionType) << "Event base dispatch success!";
MSLOG_IF(MsLogLevel::kError, ret == 1, NoExceptionType)
<< "Event base dispatch failed with no events pending or active!";
MSLOG_IF(mindspore::ERROR, ret == -1, NoExceptionType) << "Event base dispatch failed with error occurred!";
MSLOG_IF(mindspore::EXCEPTION, ret < -1, AbortedError) << "Event base dispatch with unexpected error code!";
MSLOG_IF(MsLogLevel::kError, ret == -1, NoExceptionType) << "Event base dispatch failed with error occurred!";
MSLOG_IF(MsLogLevel::kException, ret < -1, AbortedError) << "Event base dispatch with unexpected error code!";
}
void TcpServer::Stop() {

View File

@ -58,8 +58,10 @@ else()
ms_protobuf_generate(PROTO_SRCS PROTO_HDRS ${PROTO_FILE})
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT MSVC)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF")
endif()
add_compile_definitions(BUILDING_DLL)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \

View File

@ -332,7 +332,7 @@ void SynchronizeSequenceNodesElementsUseFlagsInner(const AnfNodeWeakPtrList &seq
}
void CheckSequenceNodesValid(const AnfNodeWeakPtrList &sequence_nodes) {
if (!IS_OUTPUT_ON(DEBUG)) {
if (!IS_OUTPUT_ON(MsLogLevel::kDebug)) {
return;
}
if (sequence_nodes.size() <= 1) {

View File

@ -25,7 +25,7 @@
#include "utils/macros.h"
namespace mindspore::api {
enum class LogLevel : uint8_t { DEBUG = 0, INFO, WARNING, ERROR, EXCEPTION };
enum class LogLevel : uint8_t { kDebug = 0, kInfo, kWarning, kError, kException };
class LogWriterImpl;
@ -90,11 +90,11 @@ class MIND_API LogWriter {
#define MIND_LOG_IF(L) \
if (MIND_LOG_WRITER::IsEnabled(MIND_LOG_LEVEL(L))) MIND_LOG_WRITE(L)
#define MIND_LOG_DEBUG MIND_LOG_IF(DEBUG)
#define MIND_LOG_INFO MIND_LOG_IF(INFO)
#define MIND_LOG_WARNING MIND_LOG_IF(WARNING)
#define MIND_LOG_ERROR MIND_LOG_IF(ERROR)
#define MIND_LOG_EXCEPTION MIND_LOG_THROW(EXCEPTION)
#define MIND_LOG_DEBUG MIND_LOG_IF(kDebug)
#define MIND_LOG_INFO MIND_LOG_IF(kInfo)
#define MIND_LOG_WARNING MIND_LOG_IF(kWarning)
#define MIND_LOG_ERROR MIND_LOG_IF(kError)
#define MIND_LOG_EXCEPTION MIND_LOG_THROW(kException)
#define MIND_LOG(level) MIND_LOG_##level
#if !defined(MIND_LOG_NO_MS_LOG) && !defined(MS_LOG)

View File

@ -22,18 +22,18 @@
namespace mindspore::api {
static MsLogLevel ToMsLogLevel(LogLevel level) {
switch (level) {
case LogLevel::DEBUG:
return MsLogLevel::DEBUG;
case LogLevel::INFO:
return MsLogLevel::INFO;
case LogLevel::WARNING:
return MsLogLevel::WARNING;
case LogLevel::ERROR:
return MsLogLevel::ERROR;
case LogLevel::EXCEPTION:
return MsLogLevel::EXCEPTION;
case LogLevel::kDebug:
return MsLogLevel::kDebug;
case LogLevel::kInfo:
return MsLogLevel::kInfo;
case LogLevel::kWarning:
return MsLogLevel::kWarning;
case LogLevel::kError:
return MsLogLevel::kError;
case LogLevel::kException:
return MsLogLevel::kException;
default:
return MsLogLevel::EXCEPTION;
return MsLogLevel::kException;
}
}

View File

@ -40,11 +40,11 @@ constexpr auto kSplitLine = "\n-------------------------------------------------
constexpr const char *ANDROID_LOG_TAG = "MS_LITE";
#endif
// set default log level to WARNING for all sub modules
int g_ms_submodule_log_levels[NUM_SUBMODUES] = {WARNING};
int g_ms_submodule_log_levels[NUM_SUBMODUES] = {MsLogLevel::kWarning};
#if defined(_WIN32) || defined(_WIN64)
enum MsLogLevel this_thread_max_log_level = EXCEPTION;
enum MsLogLevel this_thread_max_log_level = MsLogLevel::kException;
#else
thread_local enum MsLogLevel this_thread_max_log_level = EXCEPTION;
thread_local enum MsLogLevel this_thread_max_log_level = MsLogLevel::kException;
#endif
#ifdef USE_GLOG
@ -82,13 +82,13 @@ static std::string GetLogLevel(MsLogLevel level) {
// convert MsLogLevel to corresponding glog level
static int GetGlogLevel(MsLogLevel level) {
switch (level >= this_thread_max_log_level ? this_thread_max_log_level : level) {
case DEBUG:
case INFO:
case MsLogLevel::kDebug:
case MsLogLevel::kInfo:
return google::GLOG_INFO;
case WARNING:
case MsLogLevel::kWarning:
return google::GLOG_WARNING;
case ERROR:
case EXCEPTION:
case MsLogLevel::kError:
case MsLogLevel::kException:
default:
return google::GLOG_ERROR;
}
@ -111,13 +111,13 @@ static int GetThresholdLevel(const std::string &threshold) {
#undef google
#elif defined(BUILD_CORE_RUNTIME)
const char *EnumStrForMsLogLevel(MsLogLevel level) {
if (level == MsLogLevel::DEBUG) {
if (level == MsLogLevel::kDebug) {
return "DEBUG";
} else if (level == MsLogLevel::INFO) {
} else if (level == MsLogLevel::kInfo) {
return "INFO";
} else if (level == MsLogLevel::WARNING) {
} else if (level == MsLogLevel::kWarning) {
return "WARNING";
} else if (level == MsLogLevel::ERROR) {
} else if (level == MsLogLevel::kError) {
return "ERROR";
} else {
return "NO_LEVEL";
@ -127,13 +127,13 @@ const char *EnumStrForMsLogLevel(MsLogLevel level) {
#if defined(__ANDROID__) || defined(ANDROID)
static int GetAndroidLogLevel(MsLogLevel level) {
switch (level) {
case MsLogLevel::DEBUG:
case MsLogLevel::kDebug:
return ANDROID_LOG_DEBUG;
case MsLogLevel::INFO:
case MsLogLevel::kInfo:
return ANDROID_LOG_INFO;
case MsLogLevel::WARNING:
case MsLogLevel::kWarning:
return ANDROID_LOG_WARN;
case MsLogLevel::ERROR:
case MsLogLevel::kError:
default:
return ANDROID_LOG_ERROR;
}
@ -152,14 +152,14 @@ static int GetAndroidLogLevel(MsLogLevel level) {
// convert MsLogLevel to corresponding slog level
static int GetSlogLevel(MsLogLevel level) {
switch (level) {
case DEBUG:
case MsLogLevel::kDebug:
return DLOG_DEBUG;
case INFO:
case MsLogLevel::kInfo:
return DLOG_INFO;
case WARNING:
case MsLogLevel::kWarning:
return DLOG_WARN;
case ERROR:
case EXCEPTION:
case MsLogLevel::kError:
case MsLogLevel::kException:
default:
return DLOG_ERROR;
}
@ -379,7 +379,7 @@ void LogWriter::operator^(const LogStream &stream) const {
thread_local bool running = false;
if (!running) {
running = true;
if (this_thread_max_log_level >= EXCEPTION) {
if (this_thread_max_log_level >= MsLogLevel::kException) {
RemoveLabelBeforeOutputLog(msg);
}
if (trace_provider_ != nullptr) {
@ -578,7 +578,7 @@ bool ParseLogLevel(const std::string &str_level, MsLogLevel *ptr_level) {
int ch = str_level.c_str()[0];
constexpr char number_start = '0';
ch = ch - number_start; // subtract ASCII code of '0', which is 48
if (ch >= static_cast<int>(DEBUG) && ch <= static_cast<int>(EXCEPTION)) {
if (ch >= static_cast<int>(MsLogLevel::kDebug) && ch <= static_cast<int>(MsLogLevel::kException)) {
if (ptr_level != nullptr) {
*ptr_level = static_cast<MsLogLevel>(ch);
}
@ -592,13 +592,13 @@ static MsLogLevel GetGlobalLogLevel() {
#ifdef USE_GLOG
return static_cast<MsLogLevel>(FLAGS_v);
#else
int log_level = WARNING; // set default log level to WARNING
int log_level = MsLogLevel::kWarning; // set default log level to WARNING
auto str_level = GetEnv("GLOG_v");
if (str_level.size() == 1) {
int ch = str_level.c_str()[0];
constexpr char number_start = '0';
ch = ch - number_start; // subtract ASCII code of '0', which is 48
if (ch >= DEBUG && ch <= EXCEPTION) {
if (ch >= MsLogLevel::kDebug && ch <= MsLogLevel::kException) {
log_level = ch;
}
}
@ -725,7 +725,7 @@ MS_CORE_API void common_log_init(void) {
FLAGS_logbufsecs = 0;
// Set default log level to WARNING
if (mindspore::GetEnv("GLOG_v").empty()) {
FLAGS_v = static_cast<int>(mindspore::WARNING);
FLAGS_v = static_cast<int>(mindspore::MsLogLevel::kWarning);
}
// Set default log file mode to 0640

View File

@ -38,6 +38,9 @@
#else
#include "toolchain/slog.h"
#endif
#undef SM_DEBUG
// NOTICE: when relative path of 'log_adapter.h' changed, macro 'LOG_HDR_FILE_REL_PATH' must be changed
#define LOG_HDR_FILE_REL_PATH "mindspore/core/utils/log_adapter.h"
@ -157,7 +160,7 @@ class LogStream {
std::shared_ptr<std::stringstream> sstream_;
};
enum MsLogLevel : int { DEBUG = 0, INFO, WARNING, ERROR, EXCEPTION };
enum MsLogLevel : int { kDebug = 0, kInfo, kWarning, kError, kException };
enum SubModuleId : int {
SM_UNKNOWN = 0, // unknown submodule
@ -229,7 +232,7 @@ MS_EXPORT extern enum MsLogLevel this_thread_max_log_level;
MS_EXPORT extern thread_local enum MsLogLevel this_thread_max_log_level;
class TryCatchGuard {
public:
TryCatchGuard() : origin_log_level_(this_thread_max_log_level) { this_thread_max_log_level = MsLogLevel::WARNING; }
TryCatchGuard() : origin_log_level_(this_thread_max_log_level) { this_thread_max_log_level = MsLogLevel::kWarning; }
~TryCatchGuard() { this_thread_max_log_level = origin_log_level_; }
private:
@ -284,13 +287,13 @@ class MS_CORE_API LogWriter {
excp_type) < mindspore::LogStream()
#if !defined(BUILD_LITE_INFERENCE) || defined(BUILD_CORE_RUNTIME)
#define MSLOG_THROW(excp_type) \
mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), mindspore::EXCEPTION, SUBMODULE_ID, \
excp_type) ^ \
#define MSLOG_THROW(excp_type) \
mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), mindspore::kException, \
SUBMODULE_ID, excp_type) ^ \
mindspore::LogStream()
#else
#define MSLOG_THROW(excp_type) \
mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), mindspore::ERROR, SUBMODULE_ID, \
#define MSLOG_THROW(excp_type) \
mindspore::LogWriter(mindspore::LocationInfo(FILE_NAME, __LINE__, __FUNCTION__), mindspore::kError, SUBMODULE_ID, \
excp_type) < mindspore::LogStream()
#endif
@ -301,10 +304,10 @@ inline bool IS_OUTPUT_ON(enum MsLogLevel level) noexcept(true) {
#define MS_LOG(level) MS_LOG_##level
#define MS_LOG_DEBUG MSLOG_IF(mindspore::DEBUG, IS_OUTPUT_ON(mindspore::DEBUG), mindspore::NoExceptionType)
#define MS_LOG_INFO MSLOG_IF(mindspore::INFO, IS_OUTPUT_ON(mindspore::INFO), mindspore::NoExceptionType)
#define MS_LOG_WARNING MSLOG_IF(mindspore::WARNING, IS_OUTPUT_ON(mindspore::WARNING), mindspore::NoExceptionType)
#define MS_LOG_ERROR MSLOG_IF(mindspore::ERROR, IS_OUTPUT_ON(mindspore::ERROR), mindspore::NoExceptionType)
#define MS_LOG_DEBUG MSLOG_IF(mindspore::kDebug, IS_OUTPUT_ON(mindspore::kDebug), mindspore::NoExceptionType)
#define MS_LOG_INFO MSLOG_IF(mindspore::kInfo, IS_OUTPUT_ON(mindspore::kInfo), mindspore::NoExceptionType)
#define MS_LOG_WARNING MSLOG_IF(mindspore::kWarning, IS_OUTPUT_ON(mindspore::kWarning), mindspore::NoExceptionType)
#define MS_LOG_ERROR MSLOG_IF(mindspore::kError, IS_OUTPUT_ON(mindspore::kError), mindspore::NoExceptionType)
#define MS_LOG_EXCEPTION MSLOG_THROW(mindspore::NoExceptionType)
#define MS_EXCEPTION(type) MSLOG_THROW(type)