aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/vespa/log/loglevelnames.cpp
blob: 05fa6d61c1a2b1fb788a0288faf569b26c90a7de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <string.h>
#include <vespa/log/log.h>

namespace ns_log {

enum Logger::LogLevel
Logger::parseLevel(const char *lname)
{
    if (strcmp(lname, "fatal") == 0) return fatal;
    if (strcmp(lname, "error") == 0) return error;
    if (strcmp(lname, "warning") == 0) return warning;
    if (strcmp(lname, "config") == 0) return config;
    if (strcmp(lname, "info") == 0) return info;
    if (strcmp(lname, "event") == 0) return event;
    if (strcmp(lname, "debug") == 0) return debug;
    if (strcmp(lname, "spam") == 0) return spam;
    // bad level name signaled by NUM_LOGLEVELS
    return NUM_LOGLEVELS;
}

const char *Logger::logLevelNames[] = {
    "fatal",
    "error",
    "warning",
    "config",
    "info",
    "event",
    "debug",
    "spam",
    0 // converting NUM_LOGLEVELS gives null pointer
};

} // namespace