summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/efl/eina_log.rb68
-rw-r--r--spec/eina_log_spec.rb83
2 files changed, 151 insertions, 0 deletions
diff --git a/lib/efl/eina_log.rb b/lib/efl/eina_log.rb
new file mode 100644
index 0000000..d30cf43
--- /dev/null
+++ b/lib/efl/eina_log.rb
@@ -0,0 +1,68 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/native/eina_log'
+#
+module Efl
+ #
+ module EinaLog
+ #
+ COLOR_LIGHTRED ="\033[31;1m"
+ COLOR_RED ="\033[31m"
+ COLOR_LIGHTBLUE ="\033[34;1m"
+ COLOR_BLUE ="\033[34m"
+ COLOR_GREEN ="\033[32;1m"
+ COLOR_YELLOW ="\033[33;1m"
+ COLOR_ORANGE ="\033[0;33m"
+ COLOR_WHITE ="\033[37;1m"
+ COLOR_LIGHTCYAN ="\033[36;1m"
+ COLOR_CYAN ="\033[36m"
+ COLOR_RESET ="\033[0m"
+ COLOR_HIGH ="\033[1m"
+ #
+ def self.log_dom_crit dom, lvl, msg
+ file, line, func = caller[1].split ':'
+ Native.eina_log_print dom, lvl, file, func, line.to_i, msg
+ end
+ def self.log_dom_crit dom, msg
+ self._log_dom dom, :eina_log_level_critical, msg
+ end
+ def self.log_dom_err dom, msg
+ self._log_dom dom, :eina_log_level_err, msg
+ end
+ def self.log_dom_info dom, msg
+ self._log_dom dom, :eina_log_level_info, msg
+ end
+ def self.log_dom_warn dom, msg
+ self._log_dom dom, :eina_log_level_warn, msg
+ end
+ def self.log_dom_dbg dom, msg
+ self._log_dom dom, :eina_log_level_dbg, msg
+ end
+ # should never be called directly
+ def self._log lvl, msg
+ file, line, func = caller[1].split ':'
+ Native.eina_log_print Native.EINA_LOG_DOMAIN_GLOBAL, lvl, file, func, line.to_i, msg
+ end
+ #
+ def self.log_crit msg
+ self._log :eina_log_level_critical, msg
+ end
+ def self.log_err msg
+ self._log :eina_log_level_err, msg
+ end
+ def self.log_info msg
+ self._log :eina_log_level_info, msg
+ end
+ def self.log_warn msg
+ self._log :eina_log_level_warn, msg
+ end
+ def self.log_dbg msg
+ self._log :eina_log_level_dbg, msg
+ end
+ #
+ end
+ #
+end
+#
+# EOF
diff --git a/spec/eina_log_spec.rb b/spec/eina_log_spec.rb
new file mode 100644
index 0000000..9ecdc61
--- /dev/null
+++ b/spec/eina_log_spec.rb
@@ -0,0 +1,83 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/eina'
+require 'efl/eina_log'
+require './spec/helper'
+#
+describe Efl::EinaLog do
+ before(:all) {
+ Efl::Eina.init
+ EinaLog = Efl::EinaLog
+ }
+ after(:all) {
+ Efl::Eina.shutdown
+ }
+ #
+ it "level set/get" do
+ EinaLog.level_set 2
+ EinaLog.level_get.should == 2
+ EinaLog.level_set 3
+ EinaLog.level_get.should == 3
+ end
+ #
+ it "color_disable set/get" do
+ EinaLog.color_disable_set true
+ EinaLog.color_disable_get.should be_true
+ EinaLog.color_disable_set false
+ EinaLog.color_disable_get.should be_false
+ end
+ #
+ it "file_disable set/get" do
+ EinaLog.file_disable_set true
+ EinaLog.file_disable_get.should be_true
+ EinaLog.file_disable_set false
+ EinaLog.file_disable_get.should be_false
+ end
+ #
+ it "function_disable set/get" do
+ EinaLog.function_disable_set true
+ EinaLog.function_disable_get.should be_true
+ EinaLog.function_disable_set false
+ EinaLog.function_disable_get.should be_false
+ end
+ #
+ it "abort_on_critical set/get" do
+ EinaLog.abort_on_critical_set true
+ EinaLog.abort_on_critical_get.should be_true
+ EinaLog.abort_on_critical_set false
+ EinaLog.abort_on_critical_get.should be_false
+ end
+ #
+ it "abort_on_critical_level set/get" do
+ EinaLog.abort_on_critical_level_set 2
+ EinaLog.abort_on_critical_level_get.should == 2
+ EinaLog.abort_on_critical_level_set 3
+ EinaLog.abort_on_critical_level_get.should == 3
+ end
+ #
+ it "domain register, unregister, level set/get" do
+ d = EinaLog.domain_register "mydom", EinaLog::COLOR_CYAN
+ d.should > 0
+ EinaLog.domain_level_set "mydom", 2
+ EinaLog.domain_level_get("mydom").should == 2
+ EinaLog.domain_registered_level_get(d).should == 2
+ EinaLog.domain_level_set "mydom", 1
+ EinaLog.domain_level_get("mydom").should == 1
+ EinaLog.domain_registered_level_get(d).should == 1
+ EinaLog.domain_unregister d
+ end
+ #
+ it "treads enable check" do
+ EinaLog.main_thread_check.should be_true
+ EinaLog.threads_enable
+ end
+ # EAPI void eina_log_threads_enable(void);
+ # EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data);
+ #
+ # EAPI void eina_log_print(int domain, Eina_Log_Level level, const char *file, const char *function, int line, const char *fmt, ...);
+ # EAPI void eina_log_vprint(int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args);
+ # EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
+ # EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
+ # EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
+end