From 234f7eba7f997f6ed1f0d0ea8ebc0bae1485204b Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 16 Jan 2019 13:47:09 +0100 Subject: [PATCH] efl_mono: move Eina.Log.Init to class consturctor Summary: This removes the need to explicitly init the log class. Depends on D7495 Reviewers: felipealmeida, lauromoura, segfaultxavi Reviewed By: felipealmeida, segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7555 --- src/bindings/mono/eina_mono/eina_config.cs | 1 - src/bindings/mono/eina_mono/eina_log.cs | 23 +++++++++-------------- src/tests/efl_mono/Eina.cs | 7 +++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/bindings/mono/eina_mono/eina_config.cs b/src/bindings/mono/eina_mono/eina_config.cs index 6bc0397..87cedaf 100644 --- a/src/bindings/mono/eina_mono/eina_config.cs +++ b/src/bindings/mono/eina_mono/eina_config.cs @@ -14,7 +14,6 @@ public class Config { throw (new Efl.EflException("Failed to initialize Eina")); // Initialize the submodules here - Eina.Log.Init(); Eina.Error.Init(); } diff --git a/src/bindings/mono/eina_mono/eina_log.cs b/src/bindings/mono/eina_mono/eina_log.cs index 855c0f3..c17f02b 100644 --- a/src/bindings/mono/eina_mono/eina_log.cs +++ b/src/bindings/mono/eina_mono/eina_log.cs @@ -53,22 +53,17 @@ public class Log private static int domain = -1; - internal static void Init(String name="mono", String color="\033[32;1m") + static Log() { - if (domain == -1) - { - // Maybe move this check outside when other eina stuff get support? - domain = eina_log_domain_register(name, color); - if (domain < 0) - Console.WriteLine("Error: Couldn't register Eina log domain for name {0}.", name); - else - Info($"Registered mono domain with number {domain}"); - } + const String name="mono"; + const String color="\033[32;1m"; + + // Maybe move this check outside when other eina stuff get support? + domain = eina_log_domain_register(name, color); + if (domain < 0) + Console.WriteLine("Error: Couldn't register Eina log domain for name {0}.", name); else - { - Warning("Trying to initialize the log system again."); - // TODO Export the domain registration to the binding user to allow custom domains. - } + Info($"Registered mono domain with number {domain}"); } private static void EnsureDomainRegistered() diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs index db42b23..51e37f6 100644 --- a/src/tests/efl_mono/Eina.cs +++ b/src/tests/efl_mono/Eina.cs @@ -4047,5 +4047,12 @@ class TestEinaAccessor } } +class TestEinaLog +{ + public static void basic_log_usage() + { + Eina.Log.Error("This should work"); + } +} } -- 2.7.4