OpFlex Framework 1.7.0
OFLogHandler.h
Go to the documentation of this file.
1/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6/*
7 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8 *
9 * This program and the accompanying materials are made available under the
10 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 */
13
14#pragma once
15#ifndef OPFLEX_LOGGING_OFLOGHANDLER_H
16#define OPFLEX_LOGGING_OFLOGHANDLER_H
17
18#include <string>
19
20namespace opflex {
21namespace logging {
22
27
33
34
53public:
54
58 enum Level {
59 TRACE,
60 DEBUG7,
61 DEBUG6,
62 DEBUG5,
63 DEBUG4,
64 DEBUG3,
65 DEBUG2,
66 DEBUG1,
67 DEBUG0,
68 INFO,
69 WARNING,
70 ERROR,
71 FATAL,
72
73 /* keep as the last one */
74 NO_LOGGING
75 };
76
84 __attribute__((no_instrument_function));
85
86 virtual ~OFLogHandler()
87 __attribute__((no_instrument_function));
88
101 virtual void handleMessage(const std::string& file,
102 const int line,
103 const std::string& function,
104 const Level level,
105 const std::string& message) = 0;
106
113 virtual bool shouldEmit(const Level level)
114 __attribute__((no_instrument_function));
115
123 static void registerHandler(OFLogHandler& handler)
124 __attribute__((no_instrument_function));
125
133 __attribute__((no_instrument_function));
134
135protected:
140};
141
142/* @} logging */
143/* @} cpp */
144
145} /* namespace logging */
146} /* namespace opflex */
147
148#endif /* OPFLEX_LOGGING_OFLOGHANDLER_H */
OFLogHandler(Level logLevel) __attribute__((no_instrument_function))
Allocate a log handler that will log any messages with equal or greater severity than the specified l...
static void registerHandler(OFLogHandler &handler) __attribute__((no_instrument_function))
Register a custom handler as the log handler.
Level
Log levels for OpFlex framework logging.
Definition OFLogHandler.h:58
static OFLogHandler * getHandler() __attribute__((no_instrument_function))
Get the currently-active log handler.
Level logLevel_
The log level for this logger.
Definition OFLogHandler.h:139
virtual void handleMessage(const std::string &file, const int line, const std::string &function, const Level level, const std::string &message)=0
Process a single log message.
virtual bool shouldEmit(const Level level) __attribute__((no_instrument_function))
Check whether we should attempt to log at the given log level.