LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::Log Namespace Reference

Classes

struct  StdOutFlags
 Standard output flags enumeration. More...
struct  ColorFlags
 Enumeration of all log color code flags. More...
struct  ColorCodes
 Log color code structure. More...

Typedefs

using LogHandle = void*
 Opaque handle to a log callback.
using ReportCallback = std::function<void(ReportType type, const char* text, void* userData)>
 Report callback function signature.
using ReportCallbackExt = std::function<void(ReportType type, const char* text, void* userData, const ColorCodes& colors)>

Enumerations

enum class  ReportType { Default = 0 , Error }
 Report type enumeration. More...

Functions

LLGL_EXPORT void Printf (const char *format,...)
 Prints a formatted message to the log.
LLGL_EXPORT void Printf (const ColorCodes &colors, const char *format,...)
 Prints a formatted message to the log with color codes.
LLGL_EXPORT void Errorf (const char *format,...)
 Prints a formatted error message to the log.
LLGL_EXPORT void Errorf (const ColorCodes &colors, const char *format,...)
 Prints a formatted error message to the log with color codes.
LLGL_EXPORT LogHandle RegisterCallback (const ReportCallback &callback, void *userData=nullptr)
 Registers a new log callback. No log callback is specified by default, in which case the reports are ignored.
LLGL_EXPORT LogHandle RegisterCallback (const ReportCallbackExt &callback, void *userData=nullptr)
LLGL_EXPORT LogHandle RegisterCallbackReport (Report &report)
 Registers a new log callback that is forwarded to the specified Report.
LLGL_EXPORT LogHandle RegisterCallbackStd (long stdOutFlags=0)
 Registers a new log callback to the standard output streams, i.e. stdout and stderr from <stdio.h>.
LLGL_EXPORT void UnregisterCallback (LogHandle handle)
 Unregisters the specified handle from the log output.

Typedef Documentation

◆ LogHandle

using LLGL::Log::LogHandle = void*

Opaque handle to a log callback.

Remarks
This is only used to unregister a previously registered log callback.
See also
UnregisterCallback

◆ ReportCallback

using LLGL::Log::ReportCallback = std::function<void(ReportType type, const char* text, void* userData)>

Report callback function signature.

Parameters
[in]typeSpecifies the type of the report message.
[in]textPointer to a NUL-terminated string of the report text.
[in]userDataSpecifies the user data that was set in the previous call to SetReportCallback.
See also
ReportType
SetReportCallback

◆ ReportCallbackExt

using LLGL::Log::ReportCallbackExt = std::function<void(ReportType type, const char* text, void* userData, const ColorCodes& colors)>

Enumeration Type Documentation

◆ ReportType

enum class LLGL::Log::ReportType
strong

Report type enumeration.

See also
ReportCallback
Enumerator
Default 

Default report type. Usually forwarded to stdout or std::cout.

See also
Printf
Error 

Error message type. Usually forwarded to stderr or std::cerr.

See also
Errorf.

Function Documentation

◆ Errorf() [1/2]

LLGL_EXPORT void LLGL::Log::Errorf ( const char * format,
... )

Prints a formatted error message to the log.

Parameters
[in]formatSpecifies the formatted text. Same as ::printf.
Remarks
If this is called recursively, i.e. inside another log callback function, this function has no effect.
See also
Report::Errorf

◆ Errorf() [2/2]

LLGL_EXPORT void LLGL::Log::Errorf ( const ColorCodes & colors,
const char * format,
... )

Prints a formatted error message to the log with color codes.

Parameters
[in]formatSpecifies the formatted text. Same as ::printf.
[in]colorsSpecifies color codes to highlight the printed text.
Remarks
If this is called recursively, i.e. inside another log callback function, this function has no effect.
See also
Report::Errorf

◆ Printf() [1/2]

LLGL_EXPORT void LLGL::Log::Printf ( const char * format,
... )

Prints a formatted message to the log.

Parameters
[in]formatSpecifies the formatted text. Same as ::printf.
Remarks
If this is called recursively, i.e. inside another log callback function, this function has no effect.
See also
Report::Printf

◆ Printf() [2/2]

LLGL_EXPORT void LLGL::Log::Printf ( const ColorCodes & colors,
const char * format,
... )

Prints a formatted message to the log with color codes.

Parameters
[in]formatSpecifies the formatted text. Same as ::printf.
[in]colorsSpecifies color codes to highlight the printed text.
Remarks
If this is called recursively, i.e. inside another log callback function, this function has no effect.
See also
Report::Printf

◆ RegisterCallback() [1/2]

LLGL_EXPORT LogHandle LLGL::Log::RegisterCallback ( const ReportCallback & callback,
void * userData = nullptr )

Registers a new log callback. No log callback is specified by default, in which case the reports are ignored.

Parameters
[in]callbackSpecifies the new report callback. This can also be null.
[in]userDataOptional raw pointer to some user data that will be passed to the callback each time a report is generated.
Returns
Opaque handle to this log callback or null if this is called recursively, i.e. inside another log callback function. It can be used to unregister the callback.
Remarks
The reports can be generated in a multi-threaded environment. Even this function can be called on multiple threads. The functionality of the entire Log namespace is synchronized by LLGL. Use RegisterCallbackStd to forward the reports to the standard C++ I/O streams.
See also
RegisterCallbackStd

◆ RegisterCallback() [2/2]

LLGL_EXPORT LogHandle LLGL::Log::RegisterCallback ( const ReportCallbackExt & callback,
void * userData = nullptr )

◆ RegisterCallbackReport()

LLGL_EXPORT LogHandle LLGL::Log::RegisterCallbackReport ( Report & report)

Registers a new log callback that is forwarded to the specified Report.

Parameters
[out]reportSpecifies the report that will receive all log entries.
Remarks
This function forwards all log entries to the Report::Printf and Report::Errorf functions respectively.
Returns
Opaque handle to this log callback or null if this is called recursively, i.e. inside another log callback function. It can be used to unregister the callback.
See also
Report

◆ RegisterCallbackStd()

LLGL_EXPORT LogHandle LLGL::Log::RegisterCallbackStd ( long stdOutFlags = 0)

Registers a new log callback to the standard output streams, i.e. stdout and stderr from <stdio.h>.

Parameters
[in]stdOutFlagsBitwise OR combination of standard output flags (StdOutFlags). Use this to enable colored output for instance.
Returns
Opaque handle to this log callback or null if this is called recursively, i.e. inside another log callback function. It can be used to unregister the callback.
Remarks
If there already is a registered handle for the standard output, this function only returns the previously registered handle that is associated with the standard output.
See also
SetReportCallback
StdOutFlags

◆ UnregisterCallback()

LLGL_EXPORT void LLGL::Log::UnregisterCallback ( LogHandle handle)

Unregisters the specified handle from the log output.

Parameters
[in]handleSpecifies the opaque handle that was returned from a previous call to RegisterCallback, RegisterCallbackReport, or RegisterCallbackStd.
See also
RegisterCallback
RegisterCallbackReport
RegisterCallbackStd