[network-manager-fortisslvpn/th/gtk-split-and-log-bgo771544: 23/26] service: allow setting log_level via environment variable NM_VPN_LOG_LEVEL



commit 843fef34708cbfd78a3ed4dc7a2a8be647b97d64
Author: Thomas Haller <thaller redhat com>
Date:   Fri Sep 16 16:44:57 2016 +0200

    service: allow setting log_level via environment variable NM_VPN_LOG_LEVEL
    
    NetworkManager sets NM_VPN_LOG_LEVEL depending on the logging setting:
    
      $ nmcli general logging level KEEP domains VPN_PLUGIN:TRACE

 src/Makefile.am              |    8 +++++++-
 src/nm-fortisslvpn-service.c |    5 ++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f017ef2..cdd2fb3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,6 +4,12 @@ libexec_PROGRAMS = nm-fortisslvpn-service
 
 noinst_LTLIBRARIES = libnm-fortisslvpn-pppd-service-dbus.la
 
+shared_sources = \
+       $(top_srcdir)/shared/nm-service-defines.h \
+       $(top_srcdir)/shared/nm-utils/nm-shared-utils.c \
+       $(top_srcdir)/shared/nm-utils/nm-shared-utils.h \
+       $(NULL)
+
 AM_CPPFLAGS = \
        $(GLIB_CFLAGS) \
        $(LIBNM_CFLAGS) \
@@ -34,7 +40,7 @@ nm-fortisslvpn-pppd-service-dbus.c:
 ###############################################################################
 
 nm_fortisslvpn_service_SOURCES = \
-       $(top_srcdir)/shared/nm-service-defines.h \
+       $(shared_sources) \
        nm-fortisslvpn-service.c \
        nm-fortisslvpn-service.h
 
diff --git a/src/nm-fortisslvpn-service.c b/src/nm-fortisslvpn-service.c
index aacf2b8..f67cfe6 100644
--- a/src/nm-fortisslvpn-service.c
+++ b/src/nm-fortisslvpn-service.c
@@ -41,6 +41,7 @@
 
 #include "nm-ppp-status.h"
 #include "nm-fortisslvpn-pppd-service-dbus.h"
+#include "nm-utils/nm-shared-utils.h"
 #include "nm-utils/nm-vpn-plugin-macros.h"
 
 #if !defined(DIST_VERSION)
@@ -819,7 +820,9 @@ main (int argc, char *argv[])
        if (getenv ("NM_PPP_DEBUG"))
                gl.debug = TRUE;
 
-       gl.log_level = gl.debug ? LOG_INFO : LOG_NOTICE;
+       gl.log_level = _nm_utils_ascii_str_to_int64 (getenv ("NM_VPN_LOG_LEVEL"),
+                                                    10, 0, LOG_DEBUG,
+                                                    gl.debug ? LOG_INFO : LOG_NOTICE);
 
        _LOGD ("nm-fortisslvpn-service (version " DIST_VERSION ") starting...");
        _LOGD ("   uses%s --bus-name \"%s\"", bus_name_free ? "" : " default", bus_name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]