Mercurial > hg > orthanc
diff Core/Enumerations.cpp @ 1495:fbe40117eb21
improve the performance of the internal logger
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Aug 2015 18:19:32 +0200 |
parents | 60cc0ee61edb |
children | e9325f3ac496 |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Wed Aug 05 10:07:53 2015 +0200 +++ b/Core/Enumerations.cpp Thu Aug 06 18:19:32 2015 +0200 @@ -36,6 +36,8 @@ #include "OrthancException.h" #include "Toolbox.h" +#include <string.h> + namespace Orthanc { const char* EnumerationToString(HttpMethod method) @@ -368,6 +370,28 @@ } + const char* EnumerationToString(LogLevel level) + { + switch (level) + { + case LogLevel_Error: + return "ERROR"; + + case LogLevel_Warning: + return "WARNING"; + + case LogLevel_Info: + return "INFO"; + + case LogLevel_Trace: + return "TRACE"; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + } + + Encoding StringToEncoding(const char* encoding) { std::string s(encoding); @@ -493,6 +517,31 @@ } + LogLevel StringToLogLevel(const char *level) + { + if (strcmp(level, "ERROR") == 0) + { + return LogLevel_Error; + } + else if (strcmp(level, "WARNING") == 0) + { + return LogLevel_Warning; + } + else if (strcmp(level, "INFO") == 0) + { + return LogLevel_Info; + } + else if (strcmp(level, "TRACE") == 0) + { + return LogLevel_Trace; + } + else + { + throw OrthancException(ErrorCode_InternalError); + } + } + + unsigned int GetBytesPerPixel(PixelFormat format) { switch (format)