2012-07-04 12:37:42 +03:00
|
|
|
/*
|
|
|
|
* WrapSix
|
2017-05-16 09:31:40 +03:00
|
|
|
* Copyright (C) 2008-2012 xHire <xhire@wrapsix.org>
|
2012-07-04 12:37:42 +03:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2012-07-04 20:04:42 +03:00
|
|
|
* 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.
|
2012-07-04 12:37:42 +03:00
|
|
|
*
|
|
|
|
* 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
|
2012-07-04 20:04:42 +03:00
|
|
|
* GNU General Public License for more details.
|
2012-07-04 12:37:42 +03:00
|
|
|
*
|
2012-07-04 20:04:42 +03:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2012-07-04 12:37:42 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs debugging stuff to stdout, but only when compiled with debug enabled.
|
|
|
|
*
|
|
|
|
* @param msg Formatted message
|
|
|
|
* @param ... Parameters to be included in the message
|
|
|
|
*/
|
|
|
|
void log_debug(const char *msg, ...)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
fprintf(stdout, "[Debug] ");
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(stdout, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
#endif /* DEBUG */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs information to stdout.
|
|
|
|
*
|
|
|
|
* @param msg Formatted message
|
|
|
|
* @param ... Parameters to be included in the message
|
|
|
|
*/
|
|
|
|
void log_info(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
fprintf(stdout, "[Info] ");
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(stdout, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs warnings to stderr.
|
|
|
|
*
|
|
|
|
* @param msg Formatted message
|
|
|
|
* @param ... Parameters to be included in the message
|
|
|
|
*/
|
|
|
|
void log_warn(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
fprintf(stderr, "[Warning] ");
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(stderr, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs errors to stderr.
|
|
|
|
*
|
|
|
|
* @param msg Formatted message
|
|
|
|
* @param ... Parameters to be included in the message
|
|
|
|
*/
|
|
|
|
void log_error(const char *msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
fprintf(stderr, "[Error] ");
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(stderr, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|