new parser class structure
[logparse.git] / logparse / util.py
index 176903336a9e51b685fff9d7ff582b4e4bdc1c73..8f905f470b297dcf2d60d5c4722f3641267dba52 100644 (file)
@@ -8,13 +8,16 @@ import re
 import os
 import socket
 import inspect
+from systemd import journal
+from datetime import datetime, timedelta
 
 import logging
 logger = logging.getLogger(__name__)
 
-from .config import prefs
 from pkg_resources import Requirement, resource_filename
 
+from logparse import config
+
 def hostname(path): # get the hostname of current server
     hnfile = open(path, 'r')
     hn = re.search('^(\w*)\n*', hnfile.read()).group(1)
@@ -28,7 +31,7 @@ def getlocaldomain(): # get the parent fqdn of current server
     else:
         return domain[-1]
 
-def resolve(ip, fqdn = 'host-only'):        # try to resolve an ip to hostname
+def resolve(ip, fqdn=None):        # try to resolve an ip to hostname
     # Possible values for fqdn:
     #   fqdn            show full hostname and domain
     #   fqdn-implicit   show hostname and domain unless local
@@ -37,7 +40,7 @@ def resolve(ip, fqdn = 'host-only'):        # try to resolve an ip to hostname
     # resolve-domains defined in individual sections of the config take priority over global config
     
     if not fqdn:
-        fqdn = prefs['resolve-domains']
+        fqdn = config.prefs.get("logparse", "resolve-domains")
 
     if fqdn == 'ip':
         return(ip)