2 * Copyright (C) 2017 Cisco Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // @author Changxue Deng <chadeng@cisco.com>
19 #ifndef __MB_LOGGER_H__
20 #define __MB_LOGGER_H__
27 #define LOG_LEVEL_ERROR 0
28 #define LOG_LEVEL_WARN 1
29 #define LOG_LEVEL_INFO 2
30 #define LOG_LEVEL_DEBUG 3
38 static void Log(int level, const std::string &message);
39 // Variable length log
40 static void Log(int level, const char *formt, ... );
41 static void FillDateTime(char *buffer, int bufsize);
42 static void InitLogFile(const std::string &logfile);
43 // Set log level. Default is logging everything except for debug.
44 static int SetLogLevel(int level);
46 static std::ofstream* GetLogStream();
49 // This is a singleton class. Make sure nobody can create an instance.
53 static std::string log_file;
54 static std::ofstream *log_stream;
55 static const char* LOG_LEVEL[4];
56 static int log_level_;