test_logger.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef LEX_COMMON_TEST__TEST_LOGGER_H_
17 #define LEX_COMMON_TEST__TEST_LOGGER_H_
18 
20 
21 #include <aws/core/utils/logging/LogSystemInterface.h>
22 #include <aws/core/utils/logging/AWSLogging.h>
23 #include <aws/core/utils/logging/LogLevel.h>
24 
25 #include <iostream>
26 #include <cstdio>
27 #include <string>
28 
29 namespace Aws
30 {
31 namespace Utils
32 {
33 namespace Logging
34 {
38 class AWS_CORE_API TestLogSystem : public AWSLogSystem
39 {
40 public:
46  explicit TestLogSystem(Aws::Utils::Logging::LogLevel log_level = LogLevel::Trace)
47  : AWSLogSystem(log_level)
48  {}
49  virtual ~TestLogSystem() = default;
50 
51 protected:
52  void LogData(const char * log_level, const char * tag, const std::string & message)
53  {
54  std::cout << "<" << log_level << ", " << tag << ">: " << message << std::endl;
55  }
56  void LogTrace(const char * tag, const std::string & message) override
57  {
58  LogData("Trace", tag, message);
59  }
60  void LogInfo(const char * tag, const std::string & message) override
61  {
62  LogData("Info", tag, message);
63  }
64  void LogDebug(const char * tag, const std::string & message) override
65  {
66  LogData("Debug", tag, message);
67  }
68  void LogWarn(const char * tag, const std::string & message) override
69  {
70  LogData("Warn", tag, message);
71  }
72  void LogError(const char * tag, const std::string & message) override
73  {
74  LogData("Error", tag, message);
75  }
76  void LogFatal(const char * tag, const std::string & message) override
77  {
78  LogData("Fatal", tag, message);
79  }
80 };
81 
82 } // namespace Logging
83 } // namespace Utils
84 } // namespace Aws
85 
86 #endif // LEX_COMMON_TEST__TEST_LOGGER_H_
void LogTrace(const char *tag, const std::string &message) override
Definition: test_logger.h:56
void LogDebug(const char *tag, const std::string &message) override
Definition: test_logger.h:64
void LogInfo(const char *tag, const std::string &message) override
Definition: test_logger.h:60
void LogError(const char *tag, const std::string &message) override
Definition: test_logger.h:72
void LogData(const char *log_level, const char *tag, const std::string &message)
Definition: test_logger.h:52
void LogFatal(const char *tag, const std::string &message) override
Definition: test_logger.h:76
TestLogSystem(Aws::Utils::Logging::LogLevel log_level=LogLevel::Trace)
Definition: test_logger.h:46
void LogWarn(const char *tag, const std::string &message) override
Definition: test_logger.h:68


lex_common
Author(s): AWS RoboMaker
autogenerated on Sat Mar 6 2021 03:43:24