-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from Ghabry/output
Allow redirection of lcf console messages
- Loading branch information
Showing
24 changed files
with
310 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* This file is part of liblcf. Copyright (c) liblcf authors. | ||
* https://github.com/EasyRPG/liblcf - https://easyrpg.org | ||
* | ||
* liblcf is Free/Libre Open Source Software, released under the MIT License. | ||
* For the full copyright and license information, please view the COPYING | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
#ifndef LCF_OUTPUT_H | ||
#define LCF_OUTPUT_H | ||
|
||
#include "string_view.h" | ||
#include "enum_tags.h" | ||
|
||
namespace lcf { | ||
namespace LogHandler { | ||
|
||
enum class Level { | ||
Debug, | ||
Warning, | ||
Error, | ||
Highest | ||
}; | ||
|
||
static constexpr auto kLevelTags = lcf::makeEnumTags<Level>( | ||
"Debug", | ||
"Warning", | ||
"Error", | ||
"Highest" | ||
); | ||
|
||
using UserData = void*; | ||
using LogHandlerFn = void (*)(Level level, StringView message, UserData userdata); | ||
|
||
/** | ||
* Sets the output handler for all lcf logging. | ||
* The default handler prints to standard error. | ||
* | ||
* @param fn New output handler. nullptr for default handler. | ||
* @param userdata Passed to the log handler function. Is not touched by liblcf. | ||
*/ | ||
void SetHandler(LogHandlerFn fn, UserData userdata = nullptr); | ||
|
||
/** | ||
* Only report issues that have at least this log level. | ||
* Use Highest to disable logging. | ||
* Default: Debug | ||
* | ||
* @param new_level New log level | ||
*/ | ||
void SetLevel(Level new_level); | ||
|
||
} // namespace LogHandler | ||
} // namespace lcf | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.