summaryrefslogtreecommitdiff
path: root/src/candy_gear.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/candy_gear.cpp')
-rw-r--r--src/candy_gear.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/candy_gear.cpp b/src/candy_gear.cpp
index b10ed6e..2575e83 100644
--- a/src/candy_gear.cpp
+++ b/src/candy_gear.cpp
@@ -69,6 +69,33 @@ cg_mCandyGear_load_yaml(mrb_state *mrb, mrb_value self)
}
static mrb_value
+cg_mCandyGear_log(mrb_state *mrb, mrb_value self)
+{
+ const char *message;
+ mrb_sym sym_log_level;
+ Log::Level log_lvl;
+
+ mrb_get_args(mrb, "nz", &sym_log_level, &message);
+
+ if(sym_log_level == cg_core.sym_trace)
+ log_lvl = Log::Level::Trace;
+ else if(sym_log_level == cg_core.sym_debug)
+ log_lvl = Log::Level::Debug;
+ else if(sym_log_level == cg_core.sym_information)
+ log_lvl = Log::Level::Information;
+ else if(sym_log_level == cg_core.sym_warning)
+ log_lvl = Log::Level::Warning;
+ else if(sym_log_level == cg_core.sym_error)
+ log_lvl = Log::Level::Error;
+ else
+ log_lvl = Log::Level::Fatal;
+
+ cg_core.log.message(log_lvl, message);
+
+ return self;
+}
+
+static mrb_value
cg_mCandyGear_quit(mrb_state *mrb, mrb_value self)
{
cg_core.quit_game = true;
@@ -85,5 +112,7 @@ cg_candy_gear_init(mrb_state *mrb)
mrb_define_class_method(
mrb, cg_m, "load_yaml", cg_mCandyGear_load_yaml, MRB_ARGS_REQ(1));
mrb_define_class_method(
+ mrb, cg_m, "log", cg_mCandyGear_log, MRB_ARGS_REQ(2));
+ mrb_define_class_method(
mrb, cg_m, "quit", cg_mCandyGear_quit, MRB_ARGS_NONE());
}