added debug logging
parent
1d5cb738e2
commit
b0bd102d44
|
@ -21,8 +21,8 @@ __license__ = "BSD-3-Clause"
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Update:
|
class Update:
|
||||||
def __init__(self):
|
def __init__(self, logger):
|
||||||
self.version = ""
|
self.version = "2.0.5"
|
||||||
self.SID = ""
|
self.SID = ""
|
||||||
self.agent = ""
|
self.agent = ""
|
||||||
self.user = ""
|
self.user = ""
|
||||||
|
@ -65,6 +65,7 @@ class Update:
|
||||||
self.cust = ""
|
self.cust = ""
|
||||||
self.rps1 = ""
|
self.rps1 = ""
|
||||||
self.rps2 = ""
|
self.rps2 = ""
|
||||||
|
self.logger = logger
|
||||||
|
|
||||||
def callCommand(self, command=[]):
|
def callCommand(self, command=[]):
|
||||||
"""Given a command and args in a list, run the command and return its
|
"""Given a command and args in a list, run the command and return its
|
||||||
|
@ -84,9 +85,9 @@ class Update:
|
||||||
self.cpumodel = self.callCommand(['sysctl', 'hw.model']).split("\n")[0].split(" ")[1]
|
self.cpumodel = self.callCommand(['sysctl', 'hw.model']).split("\n")[0].split(" ")[1]
|
||||||
self.cpumodel = base64.b64encode(self.cpumodel.encode()).decode('utf-8')
|
self.cpumodel = base64.b64encode(self.cpumodel.encode()).decode('utf-8')
|
||||||
|
|
||||||
print(f"cpusockets = {self.cpusockets}, cpuspeed = {self.cpuspeed}")
|
self.logger.debug(f"cpusockets = {self.cpusockets}, cpuspeed = {self.cpuspeed}")
|
||||||
print(f"cputhreads = {self.cputhreads}, cpucores = {self.cpucores}")
|
self.logger.debug(f"cputhreads = {self.cputhreads}, cpucores = {self.cpucores}")
|
||||||
print(f"cpumodel = {self.cpumodel}")
|
self.logger.debug(f"cpumodel = {self.cpumodel}")
|
||||||
|
|
||||||
def toJsonString(self):
|
def toJsonString(self):
|
||||||
"""Return the object as a JSON string."""
|
"""Return the object as a JSON string."""
|
||||||
|
@ -141,10 +142,12 @@ class Update:
|
||||||
|
|
||||||
def go():
|
def go():
|
||||||
"""Run the command."""
|
"""Run the command."""
|
||||||
update = Update()
|
update = Update(_logger)
|
||||||
|
_logger.info(f"Starting to fetch results")
|
||||||
update.getCPUInfo()
|
update.getCPUInfo()
|
||||||
|
_logger.info(f"Done fetching results")
|
||||||
output = update.toJsonString()
|
output = update.toJsonString()
|
||||||
print(f"{output}")
|
_logger.debug(f"{output}")
|
||||||
|
|
||||||
def parse_args(args):
|
def parse_args(args):
|
||||||
"""Parse command line parameters
|
"""Parse command line parameters
|
||||||
|
@ -198,10 +201,10 @@ def main(args):
|
||||||
"""
|
"""
|
||||||
args = parse_args(args)
|
args = parse_args(args)
|
||||||
setup_logging(args.loglevel)
|
setup_logging(args.loglevel)
|
||||||
_logger.debug("Starting crazy calculations...")
|
_logger.debug("Log level DEBUG")
|
||||||
|
_logger.info("Log level INFO")
|
||||||
go()
|
go()
|
||||||
print("Done")
|
_logger.info("Done.")
|
||||||
_logger.info("Script ends here")
|
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
Loading…
Reference in New Issue