1 /* 2 * Copyright 2017, Andrew Lindesay <apl@lindesay.co.nz>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #include "Logger.h" 6 7 8 log_level Logger::fLevel = LOG_LEVEL_INFO; 9 10 11 log_level 12 Logger::Level() 13 { 14 return fLevel; 15 } 16 17 18 void 19 Logger::SetLevel(log_level value) 20 { 21 fLevel = value; 22 } 23 24 25 bool 26 Logger::SetLevelByName(const char *name) 27 { 28 if (strcmp(name, "off") == 0) { 29 fLevel = LOG_LEVEL_OFF; 30 } else if (strcmp(name, "info") == 0) { 31 fLevel = LOG_LEVEL_INFO; 32 } else if (strcmp(name, "debug") == 0) { 33 fLevel = LOG_LEVEL_DEBUG; 34 } else if (strcmp(name, "trace") == 0) { 35 fLevel = LOG_LEVEL_TRACE; 36 } else { 37 return false; 38 } 39 40 return true; 41 } 42 43 44 bool 45 Logger::IsInfoEnabled() 46 { 47 return fLevel >= LOG_LEVEL_INFO; 48 } 49 50 51 bool 52 Logger::IsDebugEnabled() 53 { 54 return fLevel >= LOG_LEVEL_DEBUG; 55 } 56 57 58 bool 59 Logger::IsTraceEnabled() 60 { 61 return fLevel >= LOG_LEVEL_TRACE; 62 }