!29912 Fix a logging api bug in MindAPI

Merge pull request !29912 from hewei/core_api
This commit is contained in:
i-robot 2022-02-11 07:55:30 +00:00 committed by Gitee
commit 5b360e39fb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
* Copyright 2021-2022 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ class LogStream {
/// \param[in] value The object to be written.
template <typename T>
LogStream &operator<<(T &&value) noexcept {
(void)stream_.operator<<(std::forward<T>(value));
stream_ << (std::forward<T>(value));
return *this;
}

View File

@ -407,10 +407,14 @@ TEST_F(TestMindApi, test_api_utils) {
/// Description: test logging API.
/// Expectation: logging work as expected.
TEST_F(TestMindApi, test_api_logging) {
std::string name = "mindspore";
MS_LOG(DEBUG) << "hello debug";
MS_LOG(INFO) << "hello info";
MS_LOG(WARNING) << "hello warning";
MS_LOG(ERROR) << "hello error";
MS_LOG(ERROR) << name;
MS_LOG(ERROR) << "hello " << name;
MS_LOG(ERROR) << name << " hello";
try {
MS_LOG(EXCEPTION) << "hello exception";
ASSERT_TRUE(false);