Changeset 874 for cpp/common/log.cpp


Ignore:
Timestamp:
05/05/19 06:21:06 (5 years ago)
Author:
Maciej Komosinski
Message:

Introduced a function logLevelName() to avoid potential errors, e.g. forgetting "+1" in LOG_LEVEL[level+1]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/log.cpp

    r841 r874  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    88#include "Convert.h"
    99
    10 const char* LOG_LEVEL[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
     10const char* LOG_LEVEL_ARRAY[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
    1111
    1212void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va)
     
    3131        va_end(argptr);
    3232}
     33
     34const char* logLevelName(int level)
     35{
     36        level = min(LOG_CRITICAL, max(LOG_DEBUG, level));
     37        return LOG_LEVEL_ARRAY[level + 1];
     38}
Note: See TracChangeset for help on using the changeset viewer.