From 93328bc707ef145566991118265744dc7ed7eee8 Mon Sep 17 00:00:00 2001 From: He Wei Date: Thu, 10 Feb 2022 21:09:48 +0800 Subject: [PATCH] Fix a logging api bug in MindAPI --- mindspore/core/mindapi/base/logging.h | 4 ++-- tests/ut/cpp/mindapi/mindapi_test.cc | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mindspore/core/mindapi/base/logging.h b/mindspore/core/mindapi/base/logging.h index 79b82afd083..614c541b9ae 100644 --- a/mindspore/core/mindapi/base/logging.h +++ b/mindspore/core/mindapi/base/logging.h @@ -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 LogStream &operator<<(T &&value) noexcept { - (void)stream_.operator<<(std::forward(value)); + stream_ << (std::forward(value)); return *this; } diff --git a/tests/ut/cpp/mindapi/mindapi_test.cc b/tests/ut/cpp/mindapi/mindapi_test.cc index 24ba636bffb..a92339852d6 100644 --- a/tests/ut/cpp/mindapi/mindapi_test.cc +++ b/tests/ut/cpp/mindapi/mindapi_test.cc @@ -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);