mirror of
https://github.com/NoelFB/blah.git
synced 2025-06-29 19:25:26 +08:00
simplifying logging, changing App events to std::function
This commit is contained in:
@ -1,8 +1,13 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <blah/core/log.h>
|
||||
|
||||
namespace Blah
|
||||
{
|
||||
using AppEventFn = std::function<void()>;
|
||||
using AppLogFn = std::function<void(const char* message, Log::Category category)>;
|
||||
|
||||
struct Config
|
||||
{
|
||||
const char* name;
|
||||
@ -11,15 +16,12 @@ namespace Blah
|
||||
int max_updates;
|
||||
int target_framerate;
|
||||
|
||||
void (*on_startup)();
|
||||
void (*on_shutdown)();
|
||||
void (*on_update)();
|
||||
void (*on_render)();
|
||||
void (*on_exit_request)();
|
||||
|
||||
void (*on_info)(const char* text);
|
||||
void (*on_warn)(const char* text);
|
||||
void (*on_error)(const char* text);
|
||||
AppEventFn on_startup;
|
||||
AppEventFn on_shutdown;
|
||||
AppEventFn on_update;
|
||||
AppEventFn on_render;
|
||||
AppEventFn on_exit_request;
|
||||
AppLogFn on_log;
|
||||
|
||||
Config();
|
||||
};
|
||||
|
@ -23,6 +23,9 @@
|
||||
#define BLAH_ASSERT(condition, message) \
|
||||
do { if (!(condition)) { BLAH_ERROR(message); } } while(0)
|
||||
|
||||
#define BLAH_ASSERT_FMT(condition, message, ...) \
|
||||
do { if (!(condition)) { BLAH_ERROR_FMT(message, __VA_ARGS__); } } while(0)
|
||||
|
||||
// maximum length of a print/warn/error message
|
||||
#ifndef BLAH_MESSAGE
|
||||
#define BLAH_MESSAGE 1024
|
||||
@ -32,6 +35,13 @@ namespace Blah
|
||||
{
|
||||
namespace Log
|
||||
{
|
||||
enum class Category
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
Error
|
||||
};
|
||||
|
||||
void print(const char* info, ...);
|
||||
void warn(const char* info, ...);
|
||||
void error(const char* info, ...);
|
||||
|
Reference in New Issue
Block a user