1/*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24#ifndef SHARE_LOGGING_LOGLEVEL_HPP
25#define SHARE_LOGGING_LOGLEVEL_HPP
26
27#include "memory/allocation.hpp"
28#include "utilities/macros.hpp"
29
30// The list of log levels:
31//
32// trace - Finest level of logging. Use for extensive/noisy
33// logging that can give slow-down when enabled.
34//
35// debug - A finer level of logging. Use for semi-noisy
36// logging that is does not fit the info level.
37//
38// info - General level of logging. Use for significant
39// events and/or informative summaries.
40//
41// warning - Important messages that are not strictly errors.
42//
43// error - Critical messages caused by errors.
44//
45#define LOG_LEVEL_LIST \
46 LOG_LEVEL(Trace, trace) \
47 LOG_LEVEL(Debug, debug) \
48 LOG_LEVEL(Info, info) \
49 LOG_LEVEL(Warning, warning) \
50 LOG_LEVEL(Error, error)
51
52class LogLevel : public AllStatic {
53 public:
54 enum type {
55 Off,
56#define LOG_LEVEL(name, printname) name,
57 LOG_LEVEL_LIST
58#undef LOG_LEVEL
59 Count,
60 Invalid,
61 NotMentioned,
62 First = Off + 1,
63 Last = Error,
64 Default = Warning,
65 Unspecified = Info
66 };
67
68 static const char *name(LogLevel::type level) {
69 assert(level >= 0 && level < LogLevel::Count, "Invalid level (enum value %d).", level);
70 return _name[level];
71 }
72
73 static LogLevel::type from_string(const char* str);
74 static LogLevel::type fuzzy_match(const char *level);
75
76 private:
77 static const char* _name[];
78};
79
80typedef LogLevel::type LogLevelType;
81
82#endif // SHARE_LOGGING_LOGLEVEL_HPP
83