![]() |
Gorgon Game Engine
|
Eases logging procedure by appending necessary information to the given data and streams to a standard c++ stream. More...
Public Types | |
enum | State { Message, Error, Notice, Success } |
Public Member Functions | |
Logger (bool marktime, bool markdate=false) | |
Logger (const char *section, bool marktime=true, bool markdate=false) | |
Default constructor. Allows you to specify a section. More... | |
Logger (const std::string §ion="", bool marktime=true, bool markdate=false) | |
Default constructor. Allows you to specify a section. More... | |
Logger (std::ostream &stream, const std::string §ion="", bool marktime=true, bool markdate=false) | |
~Logger () | |
void | CleanUp () |
Cleans the stream. More... | |
void | DisableColor () |
Disable color output. More... | |
void | EnableColor () |
Enables color support, however, if the underlying stream does not allow coloring this will not have any effect. More... | |
bool | GetMarkDate () const |
Returns whether date is being marked. More... | |
bool | GetMarkTime () const |
Returns whether time is being marked. More... | |
std::string | GetSection () const |
Returns the current section of this logger. More... | |
void | InitializeConsole () |
void | InitializeFile (const std::string &filename) |
Opens and initializer the logger using the given filename. More... | |
void | InitializeStream (std::ostream &stream) |
Initializes the logger to direct its input to the given stream. More... | |
bool | IsColorEnabled () const |
Whether color is enabled, a value of true is not a warranty that color output is working, use IsColorFunctional to make sure. More... | |
bool | IsColorFunctional () const |
Returns whether the color output is currently working. More... | |
template<class T_ > | |
helper | Log (const T_ &v, State state=Error) |
Streams out the given value to the underlying stream. More... | |
template<class T_ > | |
helper | operator<< (const T_ &v) |
Streams out the given value to the underlying stream. More... | |
void | SetColorEnabled (bool value) |
Sets color enabled state. More... | |
void | SetMarkDate (bool value) |
Sets whether to mark the date on log output. More... | |
void | SetMarkTime (bool value) |
Sets whether to mark the time on log output. More... | |
void | SetSection (const std::string &value) |
Sets the section of this logger. More... | |
void | SetWidth (int width) |
Sets the width to break lines from. Set to 0 to disable. More... | |
Protected Member Functions | |
void | reset (std::ostream &stream) |
Protected Attributes | |
bool | color |
Console | console |
bool | hasconsole |
bool | markdate |
bool | marktime |
bool | owner |
std::string | section |
std::ostream * | stream |
int | width |
Eases logging procedure by appending necessary information to the given data and streams to a standard c++ stream.
The log entries are prettified by indentation. The width of the output is determined for consoles, if not, 80 will be used as default. The lines for streams will not be broken automatically, unless a SetWidth function is called.
enum State |
Logger | ( | const std::string & | section = "" , |
bool | marktime = true , |
||
bool | markdate = false |
||
) |
Default constructor. Allows you to specify a section.
Logger | ( | const char * | section, |
bool | marktime = true , |
||
bool | markdate = false |
||
) |
Default constructor. Allows you to specify a section.
Logger | ( | bool | marktime, |
bool | markdate = false |
||
) |
Logger | ( | std::ostream & | stream, |
const std::string & | section = "" , |
||
bool | marktime = true , |
||
bool | markdate = false |
||
) |
~Logger | ( | ) |
References Logger::CleanUp().
void CleanUp | ( | ) |
Cleans the stream.
If it is built by this object, it will be destroyed. After this point nothing will be logged.
References Logger::console, Logger::owner, and Logger::stream.
void DisableColor | ( | ) |
Disable color output.
References Logger::color.
void EnableColor | ( | ) |
Enables color support, however, if the underlying stream does not allow coloring this will not have any effect.
You may use ForceColor to output color coding to a device that does not support color.
References Logger::color.
bool GetMarkDate | ( | ) | const |
Returns whether date is being marked.
References Logger::markdate.
bool GetMarkTime | ( | ) | const |
Returns whether time is being marked.
References Logger::marktime.
std::string GetSection | ( | ) | const |
Returns the current section of this logger.
References Logger::section.
void InitializeConsole | ( | ) |
References Logger::CleanUp(), Logger::console, Logger::owner, and Logger::stream.
void InitializeFile | ( | const std::string & | filename | ) |
Opens and initializer the logger using the given filename.
The file will automatically be closed when CleanUp is performed.
References Logger::CleanUp(), Logger::owner, and Logger::stream.
void InitializeStream | ( | std::ostream & | stream | ) |
Initializes the logger to direct its input to the given stream.
Ownership is not transferred
References Logger::CleanUp(), Logger::owner, and Logger::stream.
bool IsColorEnabled | ( | ) | const |
Whether color is enabled, a value of true is not a warranty that color output is working, use IsColorFunctional to make sure.
References Logger::color.
bool IsColorFunctional | ( | ) | const |
Returns whether the color output is currently working.
References Logger::color, Logger::console, Logger::hasconsole, and Console::IsColorSupported().
Streams out the given value to the underlying stream.
This function will automatically add requested information in front. Always cascade entries. Every time a new logger << ...
is called, header information will be printed out. You may use std::endl in your logs, but a new line will be added for all entries. An extra empty line will be inserted for multiline entries. Do not use "\n" as it will not be detected. ,
References Logger::console, Gorgon::Graphics::Color::Cyan, Logger::Error, Logger::helper, Logger::IsColorFunctional(), Logger::markdate, Logger::marktime, Logger::Message, Date::Now(), Logger::reset(), Logger::section, Console::SetBold(), Console::SetColor(), Logger::stream, and Logger::width.
helper operator<< | ( | const T_ & | v | ) |
Streams out the given value to the underlying stream.
This function will automatically add requested information in front. Always cascade entries. Every time a new logger << ...
is called, header information will be printed out. You may use std::endl in your logs, but a new line will be added for all entries. An extra empty line will be inserted for multiline entries. Do not use "\n" as it will not be detected. Message state is used for this case.
References Logger::Log(), and Logger::Message.
|
protected |
References Logger::console, and Console::Reset().
void SetColorEnabled | ( | bool | value | ) |
Sets color enabled state.
If color is enabled and the underlying stream does not allow coloring setting coloring to true will not have any effect. You may use ForceColor to output color coding to a device that does not support color.
References Logger::color.
void SetMarkDate | ( | bool | value | ) |
Sets whether to mark the date on log output.
References Logger::markdate.
void SetMarkTime | ( | bool | value | ) |
Sets whether to mark the time on log output.
References Logger::marktime.
void SetSection | ( | const std::string & | value | ) |
Sets the section of this logger.
References Logger::section.
void SetWidth | ( | int | width | ) |
Sets the width to break lines from. Set to 0 to disable.
References Logger::width.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |