Files
motion/src/logger.hpp
2024-04-08 16:36:48 -06:00

66 lines
2.8 KiB
C++

/*
* This file is part of MotionPlus.
*
* MotionPlus 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.
*
* MotionPlus 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 MotionPlus. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef _INCLUDE_LOGGER_HPP_
#define _INCLUDE_LOGGER_HPP_
/* Logging mode */
#define LOGMODE_NONE 0 /* No logging */
#define LOGMODE_FILE 1 /* Log messages to file */
#define LOGMODE_SYSLOG 2 /* Log messages to syslog */
#define NO_ERRNO 0 /* Flag to avoid how message associated to errno */
#define SHOW_ERRNO 1 /* Flag to show message associated to errno */
/* Log levels */
#define LOG_ALL 9
#define EMG 1
#define ALR 2
#define CRT 3
#define ERR 4
#define WRN 5
#define NTC 6
#define INF 7
#define DBG 8
#define ALL 9
#define LEVEL_DEFAULT NTC
/* Log types */
#define TYPE_CORE 1 /* Core logs */
#define TYPE_STREAM 2 /* Stream logs */
#define TYPE_ENCODER 3 /* Encoder logs */
#define TYPE_NETCAM 4 /* Netcam logs */
#define TYPE_DB 5 /* Database logs */
#define TYPE_EVENTS 6 /* Events logs */
#define TYPE_TRACK 7 /* Track logs */
#define TYPE_VIDEO 8 /* V4L1/2 Bktr logs */
#define TYPE_ALL 9 /* All type logs */
#define TYPE_DEFAULT TYPE_ALL /* Default type */
#define TYPE_DEFAULT_STR "ALL" /* Default name logs */
#define MOTPLS_LOG(x, y, z, ...) motpls_log(x, y, z, 1, __FUNCTION__, __VA_ARGS__)
void motpls_log(int msg_level, int msg_type, int msg_err, int msg_fnc, const char *msg_fncnm, ...);
void log_init(ctx_motapp *motapp);
void log_deinit(ctx_motapp *motapp);
void log_set_level(int new_level);
void log_set_type(const char *new_logtype);
void log_init_app(ctx_motapp *motapp);
#endif /* _INCLUDE_LOGGER_HPP_ */