1919import traceback
2020
2121import solnlib .splunkenv as sp
22- import logging
22+
23+ from solnlib .log import Logs
24+ logger = Logs ().get_logger (__name__ )
2325
2426
2527def _parse_modinput_configs (root , outer_block , inner_block ):
@@ -62,7 +64,7 @@ def _parse_modinput_configs(root, outer_block, inner_block):
6264
6365 confs = root .getElementsByTagName (outer_block )
6466 if not confs :
65- logging .error ("Invalid config, missing %s section" , outer_block )
67+ logger .error ("Invalid config, missing %s section" , outer_block )
6668 raise Exception (f"Invalid config, missing { outer_block } section" )
6769
6870 configs = []
@@ -71,7 +73,7 @@ def _parse_modinput_configs(root, outer_block, inner_block):
7173 config = {}
7274 stanza_name = stanza .getAttribute ("name" )
7375 if not stanza_name :
74- logging .error ("Invalid config, missing name" )
76+ logger .error ("Invalid config, missing name" )
7577 raise Exception ("Invalid config, missing name" )
7678
7779 config ["name" ] = stanza_name
@@ -107,13 +109,13 @@ def parse_modinput_configs(config_str):
107109 for tag in meta_configs .keys ():
108110 nodes = doc .getElementsByTagName (tag )
109111 if not nodes :
110- logging .error ("Invalid config, missing %s section" , tag )
112+ logger .error ("Invalid config, missing %s section" , tag )
111113 raise Exception ("Invalid config, missing %s section" , tag )
112114
113115 if nodes [0 ].firstChild and nodes [0 ].firstChild .nodeType == nodes [0 ].TEXT_NODE :
114116 meta_configs [tag ] = nodes [0 ].firstChild .data
115117 else :
116- logging .error ("Invalid config, expect text ndoe" )
118+ logger .error ("Invalid config, expect text ndoe" )
117119 raise Exception ("Invalid config, expect text ndoe" )
118120
119121 if doc .nodeName == "input" :
@@ -140,7 +142,7 @@ def get_modinput_configs_from_cli(modinput, modinput_stanza=None):
140142 cli , stdout = subprocess .PIPE , stderr = subprocess .PIPE
141143 ).communicate ()
142144 if err :
143- logging .error ("Failed to get modinput configs with error: %s" , err )
145+ logger .error ("Failed to get modinput configs with error: %s" , err )
144146 return None , None
145147 else :
146148 return parse_modinput_configs (out )
@@ -152,7 +154,7 @@ def get_modinput_config_str_from_stdin():
152154 try :
153155 return sys .stdin .read (5000 )
154156 except Exception :
155- logging .error (traceback .format_exc ())
157+ logger .error (traceback .format_exc ())
156158 raise
157159
158160
0 commit comments