Mana
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2025 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <string>
25#include <cstdarg>
26
27#ifdef __GNUC__
28# define LOG_PRINTF_ATTR __attribute__((__format__(__printf__, 1, 2)))
29#else
30# define LOG_PRINTF_ATTR
31#endif
32
37namespace Log
38{
42 void init();
43
47 void setLogFile(const std::string &logFilename);
48
52 void setLogToStandardOut(bool value);
53
54 void verbose(const char *log_text, ...) LOG_PRINTF_ATTR;
55 void debug(const char *log_text, ...) LOG_PRINTF_ATTR;
56 void info(const char *log_text, ...) LOG_PRINTF_ATTR;
57 void warn(const char *log_text, ...) LOG_PRINTF_ATTR;
58 void error(const char *log_text, ...) LOG_PRINTF_ATTR;
59
60 void vinfo(const char *log_text, va_list ap);
61
66 __attribute__((noreturn))
67 void critical(const std::string &error_text);
68
69} // namespace Log
70
71#undef LOG_PRINTF_ATTR
#define LOG_PRINTF_ATTR
Definition log.h:30
The Log namespace: Useful to write debug or info messages to the log file and/or console.
Definition log.h:38
void init()
Initializes the log system.
Definition log.cpp:84
void verbose(const char *log_text,...) LOG_PRINTF_ATTR
void setLogToStandardOut(bool value)
Sets whether the log should be written to standard output.
Definition log.cpp:100
void warn(const char *log_text,...) LOG_PRINTF_ATTR
void debug(const char *log_text,...) LOG_PRINTF_ATTR
void setLogFile(const std::string &logFilename)
Sets the file to log to and opens it.
Definition log.cpp:89
void info(const char *log_text,...) LOG_PRINTF_ATTR
void error(const char *log_text,...) LOG_PRINTF_ATTR
void vinfo(const char *log_text, va_list ap)