Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef LOG_CONTROL_H
12 : #define LOG_CONTROL_H
13 :
14 : #include "log.h"
15 :
16 : // 用于将特定场景下的ERROR日志,转换为RUN_WARNING日志
17 : class LogControl {
18 : public:
19 : // 构造时初始化initState,并将当前日志级别设置为targetState
20 3 : LogControl(bool initState, bool targetState) : initState_(initState) { SetErrToWarnSwitch(targetState); }
21 :
22 : // 析构时恢复为initState
23 3 : ~LogControl() { SetErrToWarnSwitch(initState_); }
24 :
25 : private:
26 : bool initState_ = false;
27 : };
28 :
29 : #endif // LOG_CONTROL_H
|