diff --git a/.gitignore b/.gitignore index 5c9b581..4ccfb63 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ flake.lock # Editor files .clangd .vscode/ +massif.out # 42 files bircd/ diff --git a/include/core/logs.hpp b/include/core/logs.hpp new file mode 100644 index 0000000..d7efc90 --- /dev/null +++ b/include/core/logs.hpp @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* logs.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/15 12:25:58 by rparodi #+# #+# */ +/* Updated: 2025/05/15 12:38:10 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include +#include "color.hpp" + +#define DEBUG_MSG(str) "print_debug(str, __FILE__, __LINE__)" +#define ERROR_MSG(str) "print_error(str, __FILE__, __LINE__)" +#define WARNING_MSG(str) "print_warning(str, __FILE__, __LINE__)" +#define INFO_MSG(str) "print_info(str, __FILE__, __LINE__)" +#define SUCCESS_MSG(str) "print_success(str, __FILE__, __LINE__)" + + +#ifndef DEBUG +#define DEBUG 0 +#define LOG "" +#endif + +void print_debug(const char *str, const char *file, int line); +void print_error(const char *str, const char *file, int line); +void print_warning(const char *str, const char *file, int line); +void print_info(const char *str, const char *file, int line); +void print_success(const char *str, const char *file, int line); diff --git a/sources/core/logs.cpp b/sources/core/logs.cpp new file mode 100644 index 0000000..8b75ec8 --- /dev/null +++ b/sources/core/logs.cpp @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* logs.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/15 12:29:56 by rparodi #+# #+# */ +/* Updated: 2025/05/15 12:38:56 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "logs.hpp" + +void print_debug(const char *str, const char *file, int line) +{ + if (DEBUG) + std::cout << CLR_CYAN << "\tDebug: " << str << "(" << file << ":" << line << ")" << CLR_RESET << std::endl; +} + +void print_error(const char *str, const char *file, int line) +{ + std::cerr << CLR_RED << "\tError: " << str << "(" << file << ":" << line << ")" << CLR_RESET << std::endl; +} + +void print_warning(const char *str, const char *file, int line) +{ + std::cerr << CLR_YELLOW << "\tWarning: " << str << "(" << file << ":" << line << ")" << CLR_RESET << std::endl; +} + +void print_info(const char *str, const char *file, int line) +{ + std::cout << CLR_GREY << "\tInfo: " << str << "(" << file << ":" << line << ")" << CLR_RESET << std::endl; +} + +void print_success(const char *str, const char *file, int line) +{ + std::cout << CLR_GREEN << "\tSuccess: " << str << "(" << file << ":" << line << ")" << CLR_RESET << std::endl; +}