 |
Gorgon Game Engine
|
Go to the documentation of this file.
9 #include "../Utils/Console.h"
11 namespace Gorgon {
namespace Utils {
28 bool extraenter =
false;
30 helper() : parent(nullptr) { }
32 helper(
Logger *parent,
int shift,
bool extraenter) : parent(parent), shift(shift), extraenter(extraenter) {
40 extraenter=h.extraenter;
51 extraenter=h.extraenter;
67 (*parent->
stream)<<std::endl;
73 using endl_t = decltype(&std::endl<
char, std::char_traits<char>>);
76 if(!parent)
return *
this;
78 (*parent->
stream) << std::endl << std::string(shift,
' ');
84 throw std::runtime_error(
"Logging failed");
93 if(!parent)
return *
this;
99 throw std::runtime_error(
"Logging failed");
159 stream=
new std::ofstream(filename);
202 if(!this->
stream)
return {
nullptr, 0,
false};
207 if(headw) headw += 2;
217 h = {
this, headw,
false};
260 stream << (state ==
Error ?
"Error! : " :
"Success: ");
264 return std::move(h << v);
266 return {
nullptr, 0,
false};
354 void colorize(
State state) {
366 # define DEBUGONLY(action)
368 # define DEBUGONLY(action) action
void SetMarkTime(bool value)
Sets whether to mark the time on log output.
Definition: Logging.h:281
ColorSupportLevel
Level of support for color.
Definition: Console.h:35
void EnableColor()
Enables color support, however, if the underlying stream does not allow coloring this will not have a...
Definition: Logging.h:303
helper operator<<(const T_ &v)
Streams out the given value to the underlying stream.
Definition: Logging.h:187
bool markdate
Definition: Logging.h:345
friend class helper
Definition: Logging.h:20
std::ostream * stream
Definition: Logging.h:341
Color
The colors that can be used for console coloring. This is a safe list.
Definition: Console.h:47
void Reset()
Resets terminal attributes.
constexpr RGBA White
Definition: Color.h:731
void SetColorEnabled(bool value)
Sets color enabled state.
Definition: Logging.h:316
std::string GetEnvVar(const std::string &var)
Returns the value of an environment variable.
Definition: Linux.cpp:17
~Logger()
Definition: Logging.h:133
bool color
Definition: Logging.h:348
void SetColor(Color color)
Sets the color to the given value, avoid, black and white as console can have its background color re...
bool owner
Definition: Logging.h:342
@ Red
Definition: Console.h:51
Logger(const std::string §ion="", bool marktime=true, bool markdate=false)
Default constructor. Allows you to specify a section.
Definition: Logging.h:116
@ None
Color is not supported.
Definition: Console.h:37
Logger(bool marktime, bool markdate=false)
Definition: Logging.h:125
constexpr RGBA Cyan
Definition: Color.h:640
@ Safelist
Only colors in the safelist can be used.
Definition: Console.h:40
void CleanUp()
Cleans the stream.
Definition: Logging.h:166
basic_Size< int > Size
Definition: Size.h:385
void SetBold(bool bold=true)
Sets terminal font to bold or normal.
bool IsColorFunctional() const
Returns whether the color output is currently working.
Definition: Logging.h:327
@ Notice
Definition: Logging.h:111
@ White
Definition: Console.h:50
bool marktime
Definition: Logging.h:344
void InitializeStream(std::ostream &stream)
Initializes the logger to direct its input to the given stream.
Definition: Logging.h:146
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
int width
Definition: Logging.h:349
bool GetMarkTime() const
Returns whether time is being marked.
Definition: Logging.h:286
Console manipulation functions. Not thread safe. Current only std::cout is supported.
Definition: Console.h:14
void InitializeConsole()
Definition: Logging.h:137
void SetWidth(int width)
Sets the width to break lines from. Set to 0 to disable.
Definition: Logging.h:176
constexpr RGBA Yellow
Definition: Color.h:629
Eases logging procedure by appending necessary information to the given data and streams to a standar...
Definition: Logging.h:19
basic_Point< int > Point
Definition: Point.h:598
@ Success
Definition: Logging.h:112
void InitializeFile(const std::string &filename)
Opens and initializer the logger using the given filename.
Definition: Logging.h:156
bool GetMarkDate() const
Returns whether date is being marked.
Definition: Logging.h:296
@ Blue
Definition: Console.h:53
void SetSection(const std::string &value)
Sets the section of this logger.
Definition: Logging.h:271
bool IsColorEnabled() const
Whether color is enabled, a value of true is not a warranty that color output is working,...
Definition: Logging.h:322
static Date Now()
Returns current time.
Definition: Time.h:171
State
Definition: Logging.h:108
Logger(std::ostream &stream, const std::string §ion="", bool marktime=true, bool markdate=false)
Definition: Logging.h:127
@ Error
Definition: Logging.h:110
bool IsColorSupported() const
Returns if the color is supported by this console.
Definition: Console.h:63
void DisableColor()
Disable color output.
Definition: Logging.h:309
helper Log(const T_ &v, State state=Error)
Streams out the given value to the underlying stream.
Definition: Logging.h:200
@ Cyan
Definition: Console.h:52
@ Yellow
Definition: Console.h:54
@ RGB
Graphics::RGBA can be used for color.
Definition: Console.h:43
@ Message
Definition: Logging.h:109
void reset(std::ostream &stream)
Definition: Logging.h:334
void SetMarkDate(bool value)
Sets whether to mark the date on log output.
Definition: Logging.h:291
@ Black
Definition: Console.h:49
constexpr RGBA Green
Definition: Color.h:619
std::string GetSection() const
Returns the current section of this logger.
Definition: Logging.h:276
bool hasconsole
Definition: Logging.h:347
@ Green
Definition: Console.h:56
constexpr RGBA Red
Definition: Color.h:623
std::string section
Definition: Logging.h:351
Logger(const char *section, bool marktime=true, bool markdate=false)
Default constructor. Allows you to specify a section.
Definition: Logging.h:121
@ Magenta
Definition: Console.h:55
Console console
Definition: Logging.h:339