From 9a63974bbfed1f5f9da53c19551a127eedab967d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 25 Sep 2018 18:49:09 +0200 Subject: Add `logger_init()` to init 'stderrlog' Trying to see if this works. If I call the init function over FFI and then call functions that use the error macro, will logging work? --- src/cocoa_bridge.rs | 6 ++++++ src/lib.rs | 1 + 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs index 5c7c40d..189d504 100644 --- a/src/cocoa_bridge.rs +++ b/src/cocoa_bridge.rs @@ -8,6 +8,7 @@ use autopilot::key::type_string; // use cocoa::base::nil; // use cocoa::foundation::{NSArray, NSAutoreleasePool, NSDictionary}; use libc::{c_char, size_t}; +use stderrlog; use xdg; use {HeadphoneButton, MapGroup, MapKind}; @@ -101,6 +102,11 @@ pub struct State { map_group: Option, } +#[no_mangle] +pub extern "C" fn logger_init() { + stderrlog::new().module(module_path!()).init().unwrap(); +} + #[no_mangle] pub extern "C" fn state_new() -> *mut State { Box::into_raw(Box::new(State::default())) diff --git a/src/lib.rs b/src/lib.rs index 13d70e8..795d1d9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ extern crate libc; #[macro_use] extern crate log; +extern crate stderrlog; extern crate xdg; mod cocoa_bridge; -- cgit v1.2.3