Steppable 0.0.1
A CAS project written from scratch in C++
Loading...
Searching...
No Matches
output.hpp
1/**************************************************************************************************
2 * Copyright (c) 2023-2025 NWSOFT *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy *
5 * of this software and associated documentation files (the "Software"), to deal *
6 * in the Software without restriction, including without limitation the rights *
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
8 * copies of the Software, and to permit persons to whom the Software is *
9 * furnished to do so, subject to the following conditions: *
10 * *
11 * The above copyright notice and this permission notice shall be included in all *
12 * copies or substantial portions of the Software. *
13 * *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
20 * SOFTWARE. *
21 **************************************************************************************************/
22
43
44#pragma once
45
46#include "colors.hpp"
47#include "format.hpp"
48#include "logging.hpp"
49#include "symbols.hpp"
50
51#include <iostream>
52#include <string>
53
58namespace steppable::output
59{
60 using namespace steppable::__internals;
61 using namespace steppable::__internals::utils;
62 using namespace steppable::__internals::symbols;
63
79 template<typename T>
80 void error(const std::string& name, const std::basic_string<T>& msg, const std::vector<std::string>& args = {})
81 {
82 auto formattedMsg = format::format(msg, args);
83 std::cerr << colors::red << formats::bold << LARGE_DOT << name << " - ERROR: " << reset << colors::red;
84 std::cerr << formattedMsg << reset << '\n';
85
86 // Write to the log file
87 auto logger = logging::Logger(name, "steppable.log");
88 logger.error(formattedMsg);
89 }
90
106 template<typename T>
107 void warning(const std::basic_string<T>& name,
108 const std::basic_string<T>& msg,
109 const std::vector<std::string>& args = {})
110 {
111 std::cout << colors::yellow << formats::bold << LARGE_DOT << name << " - WARNING: " << reset << colors::yellow;
112 std::cout << format::format(msg, args) << reset << '\n';
113 }
114
130 template<typename T>
131 void info(const std::basic_string<T>& name,
132 const std::basic_string<T>& msg,
133 const std::vector<std::string>& args = {})
134 {
135 std::cout << colors::brightGreen << formats::bold << LARGE_DOT << name << " - INFO: " << reset
137 std::cout << format::format(msg, args) << reset << '\n';
138 }
139} // namespace steppable::output
The Logger class provides logging functionality.
Definition logging.hpp:78
The namespace containing various unicode symbols.
Definition symbols.cpp:124
constexpr std::string_view LARGE_DOT
The large dot symbol (Unicode U+25C9)
Definition symbols.hpp:173
std::ostream & brightGreen(std::ostream &stream)
Set the text color to bright green.
Definition colors.cpp:132
std::ostream & red(std::ostream &stream)
Set the text color to red.
Definition colors.cpp:69
std::ostream & yellow(std::ostream &stream)
Set the text color to yellow.
Definition colors.cpp:83
std::ostream & bold(std::ostream &stream)
Set the text format to bold.
Definition colors.cpp:229
The namespace containing utility functions for the Steppable library.
Definition argParse.cpp:40
std::ostream & reset(std::ostream &stream)
Reset the text color and format to the default values.
Definition colors.cpp:53
The namespace containing internal functions for the Steppable library.
Definition argParse.cpp:40
Message-printing utilities for Steppable.
void warning(const std::basic_string< T > &name, const std::basic_string< T > &msg, const std::vector< std::string > &args={})
Prints a warning message.
Definition output.hpp:107
void error(const std::string &name, const std::basic_string< T > &msg, const std::vector< std::string > &args={})
Prints an error message.
Definition output.hpp:80
void info(const std::basic_string< T > &name, const std::basic_string< T > &msg, const std::vector< std::string > &args={})
Prints an info message.
Definition output.hpp:131
Untitled