ftpiiu_plugin/include/log.h

75 lines
2.3 KiB
C
Raw Normal View History

2020-04-05 21:16:16 +02:00
// ftpd is a server implementation based on the following:
// - RFC 959 (https://tools.ietf.org/html/rfc959)
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
2022-10-04 04:52:19 +02:00
// Copyright (C) 2022 Michael Theall
2020-04-05 21:16:16 +02:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <cstdarg>
#include <string>
#include <string_view>
2020-04-10 04:21:25 +02:00
/// \brief Log level
enum LogLevel
2020-04-05 21:16:16 +02:00
{
2024-04-27 12:25:32 +02:00
DEBUGLOG,
2020-04-10 04:21:25 +02:00
INFO,
ERROR,
COMMAND,
RESPONSE,
};
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Draw log
void drawLog ();
2020-04-06 07:36:03 +02:00
2022-10-04 04:52:19 +02:00
#ifndef CLASSIC
/// \brief Get log
std::string getLog ();
#endif
2020-04-10 04:21:25 +02:00
/// \brief Add debug message to bound log
/// \param fmt_ Message format
__attribute__ ((format (printf, 1, 2))) void debug (char const *fmt_, ...);
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add info message to bound log
/// \param fmt_ Message format
__attribute__ ((format (printf, 1, 2))) void info (char const *fmt_, ...);
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add error message to bound log
/// \param fmt_ Message format
__attribute__ ((format (printf, 1, 2))) void error (char const *fmt_, ...);
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add command message to bound log
/// \param fmt_ Message format
__attribute__ ((format (printf, 1, 2))) void command (char const *fmt_, ...);
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add response message to bound log
/// \param fmt_ Message format
__attribute__ ((format (printf, 1, 2))) void response (char const *fmt_, ...);
2020-04-05 21:16:16 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add log message to bound log
/// \param level_ Log level
/// \param fmt_ Message format
/// \param ap_ Message arguments
void addLog (LogLevel level_, char const *fmt_, va_list ap_);
2020-04-06 07:36:03 +02:00
2020-04-10 04:21:25 +02:00
/// \brief Add log message to bound log
/// \param level_ Log level
/// \param message_ Message to log
void addLog (LogLevel level_, std::string_view message_);