1 #ifndef LUME_LOG_LOGGER_H 2 #define LUME_LOG_LOGGER_H 3 4 /* 5 * Copyright (C) 2023 Huawei Device Co., Ltd. 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include <lume/Log.h> 20 21 #include <mutex> 22 #include <vector> 23 #include <memory> 24 25 26 namespace lume 27 { 28 29 class Logger : public ILogger 30 { 31 public: 32 static const char* getLogLevelName(LogLevel aLogLevel, bool aShortName); 33 34 Logger(bool aDefaultOutputs); 35 virtual ~Logger(); 36 37 void VLog(LogLevel aLogLevel, const char *aFilename, int aLinenumber, const char *aFormat, va_list aArgs) override; 38 FORMAT_FUNC(5, 6) void log(LogLevel aLogLevel, const char *aFilename, int aLinenumber, FORMAT_ATTRIBUTE const char *aFormat, ...) override; 39 40 FORMAT_FUNC(6, 7) bool logAssert(const char *aFilename, int aLinenumber, bool expression, const char *expressionString, FORMAT_ATTRIBUTE const char *aFormat, ...) override; 41 42 LogLevel getLogLevel() const override; 43 void setLogLevel(LogLevel aLogLevel) override; 44 45 void addOutput(std::unique_ptr<IOutput> aOutput) override; 46 47 private: 48 LogLevel mLogLevel = LogLevel::Verbose; 49 std::mutex mLoggerMutex; 50 51 std::vector< std::unique_ptr<IOutput> > mOutputs; 52 }; 53 54 55 } // lume 56 57 #endif // LUME_LOG_LOGGER_H 58