Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1494:a13581480b1f | 1495:fbe40117eb21 |
---|---|
34 #include "Enumerations.h" | 34 #include "Enumerations.h" |
35 | 35 |
36 #include "OrthancException.h" | 36 #include "OrthancException.h" |
37 #include "Toolbox.h" | 37 #include "Toolbox.h" |
38 | 38 |
39 #include <string.h> | |
40 | |
39 namespace Orthanc | 41 namespace Orthanc |
40 { | 42 { |
41 const char* EnumerationToString(HttpMethod method) | 43 const char* EnumerationToString(HttpMethod method) |
42 { | 44 { |
43 switch (method) | 45 switch (method) |
366 throw OrthancException(ErrorCode_ParameterOutOfRange); | 368 throw OrthancException(ErrorCode_ParameterOutOfRange); |
367 } | 369 } |
368 } | 370 } |
369 | 371 |
370 | 372 |
373 const char* EnumerationToString(LogLevel level) | |
374 { | |
375 switch (level) | |
376 { | |
377 case LogLevel_Error: | |
378 return "ERROR"; | |
379 | |
380 case LogLevel_Warning: | |
381 return "WARNING"; | |
382 | |
383 case LogLevel_Info: | |
384 return "INFO"; | |
385 | |
386 case LogLevel_Trace: | |
387 return "TRACE"; | |
388 | |
389 default: | |
390 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
391 } | |
392 } | |
393 | |
394 | |
371 Encoding StringToEncoding(const char* encoding) | 395 Encoding StringToEncoding(const char* encoding) |
372 { | 396 { |
373 std::string s(encoding); | 397 std::string s(encoding); |
374 Toolbox::ToUpperCase(s); | 398 Toolbox::ToUpperCase(s); |
375 | 399 |
488 { | 512 { |
489 return ImageFormat_Png; | 513 return ImageFormat_Png; |
490 } | 514 } |
491 | 515 |
492 throw OrthancException(ErrorCode_ParameterOutOfRange); | 516 throw OrthancException(ErrorCode_ParameterOutOfRange); |
517 } | |
518 | |
519 | |
520 LogLevel StringToLogLevel(const char *level) | |
521 { | |
522 if (strcmp(level, "ERROR") == 0) | |
523 { | |
524 return LogLevel_Error; | |
525 } | |
526 else if (strcmp(level, "WARNING") == 0) | |
527 { | |
528 return LogLevel_Warning; | |
529 } | |
530 else if (strcmp(level, "INFO") == 0) | |
531 { | |
532 return LogLevel_Info; | |
533 } | |
534 else if (strcmp(level, "TRACE") == 0) | |
535 { | |
536 return LogLevel_Trace; | |
537 } | |
538 else | |
539 { | |
540 throw OrthancException(ErrorCode_InternalError); | |
541 } | |
493 } | 542 } |
494 | 543 |
495 | 544 |
496 unsigned int GetBytesPerPixel(PixelFormat format) | 545 unsigned int GetBytesPerPixel(PixelFormat format) |
497 { | 546 { |