2828REG_VALUE_TYPE_UNICODE_STRING_SEQUENCE = 7
2929REG_VALUE_TYPE_64BIT_LE = 11
3030
31- # Setup file logger
32- if "wcc_logger" not in globals ():
33- wcc_logger = logging .getLogger ("WCC" )
34- wcc_logger .propagate = False
35- log_filename = nxc_logger .init_log_file ()
36- log_filename = log_filename .replace ("log_" , "wcc_" )
37- wcc_logger .setLevel (logging .INFO )
38- wcc_file_handler = logging .FileHandler (log_filename )
39- wcc_file_handler .setFormatter (logging .Formatter ("%(asctime)s [%(levelname)s] %(message)s" ))
40- wcc_logger .addHandler (wcc_file_handler )
41-
4231
4332class ConfigCheck :
4433 """Class for performing the checks and holding the results"""
@@ -75,7 +64,7 @@ def run(self):
7564 def log (self , context ):
7665 result = "passed" if self .ok else "did not pass"
7766 reasons = ", " .join (self .reasons )
78- wcc_logger .info (f'{ self .connection .host } : Check "{ self .name } " { result } because: { reasons } ' )
67+ self . module . wcc_logger .info (f'{ self .connection .host } : Check "{ self .name } " { result } because: { reasons } ' )
7968 if self .module .quiet :
8069 return
8170
@@ -99,6 +88,19 @@ class NXCModule:
9988 supported_protocols = ["smb" ]
10089 opsec_safe = True
10190 multiple_hosts = True
91+
92+ def __init__ (self ):
93+ self .context = None
94+ self .module_options = None
95+
96+ self .wcc_logger = logging .getLogger ("WCC" )
97+ self .wcc_logger .propagate = False
98+ log_filename = nxc_logger .init_log_file ()
99+ log_filename = log_filename .replace ("log_" , "wcc_" )
100+ self .wcc_logger .setLevel (logging .INFO )
101+ wcc_file_handler = logging .FileHandler (log_filename )
102+ wcc_file_handler .setFormatter (logging .Formatter ("%(asctime)s [%(levelname)s] %(message)s" ))
103+ self .wcc_logger .addHandler (wcc_file_handler )
102104
103105 def options (self , context , module_options ):
104106 """
@@ -150,20 +152,15 @@ class HostChecker:
150152
151153 def __init__ (self , context , connection ):
152154 self .context = context
153- self .connection = connection
155+ self .connection = connection
154156 remoteOps = RemoteOperations (smbConnection = connection .conn , doKerberos = False )
155157 remoteOps .enableRegistry ()
156158 self .dce = remoteOps ._RemoteOperations__rrp
157159
158160 def run (self ):
159- # Prepare checks
160161 self .init_checks ()
161-
162- # Perform checks
163162 self .check_config ()
164-
165- # Check methods #
166- #################
163+
167164
168165 def init_checks (self ):
169166 # Declare the checks to do and how to do them
0 commit comments