mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-14 07:04:52 -04:00
adjusted logging format, patched $DISPLAY error
This commit is contained in:
parent
b13d212f05
commit
750713d0cf
5 changed files with 35 additions and 13 deletions
|
@ -198,9 +198,11 @@ class kmsBase:
|
||||||
loggersrv.info("SKU ID: %s" % infoDict["skuId"])
|
loggersrv.info("SKU ID: %s" % infoDict["skuId"])
|
||||||
loggersrv.info("License Status: %s" % infoDict["licenseStatus"])
|
loggersrv.info("License Status: %s" % infoDict["licenseStatus"])
|
||||||
loggersrv.info("Request Time: %s" % local_dt.strftime('%Y-%m-%d %H:%M:%S %Z (UTC%z)'))
|
loggersrv.info("Request Time: %s" % local_dt.strftime('%Y-%m-%d %H:%M:%S %Z (UTC%z)'))
|
||||||
loggersrv.mini("", extra = {'host': socket.gethostname() + " [" + self.srv_config["ip"] + "]",
|
|
||||||
'status' : infoDict["licenseStatus"],
|
if self.srv_config['loglevel'] == 'MINI':
|
||||||
'product' : infoDict["skuId"]})
|
loggersrv.mini("", extra = {'host': socket.gethostname() + " [" + self.srv_config["ip"] + "]",
|
||||||
|
'status' : infoDict["licenseStatus"],
|
||||||
|
'product' : infoDict["skuId"]})
|
||||||
|
|
||||||
if self.srv_config['sqlite'] and self.srv_config['dbSupport']:
|
if self.srv_config['sqlite'] and self.srv_config['dbSupport']:
|
||||||
sql_update(self.dbName, infoDict)
|
sql_update(self.dbName, infoDict)
|
||||||
|
|
|
@ -117,7 +117,7 @@ def client_update():
|
||||||
break
|
break
|
||||||
|
|
||||||
def client_create():
|
def client_create():
|
||||||
loggerclt.info("\n\nConnecting to %s on port %d..." % (clt_config['ip'], clt_config['port']))
|
loggerclt.info("Connecting to %s on port %d..." % (clt_config['ip'], clt_config['port']))
|
||||||
s = socket.create_connection((clt_config['ip'], clt_config['port']))
|
s = socket.create_connection((clt_config['ip'], clt_config['port']))
|
||||||
loggerclt.info("Connection successful !")
|
loggerclt.info("Connection successful !")
|
||||||
binder = pykms_RpcBind.handler(None, clt_config)
|
binder = pykms_RpcBind.handler(None, clt_config)
|
||||||
|
@ -161,9 +161,11 @@ def client_create():
|
||||||
loggerclt.info("KMS Host Current Client Count: %s" % kmsResp['currentClientCount'])
|
loggerclt.info("KMS Host Current Client Count: %s" % kmsResp['currentClientCount'])
|
||||||
loggerclt.info("KMS VL Activation Interval: %s" % kmsResp['vLActivationInterval'])
|
loggerclt.info("KMS VL Activation Interval: %s" % kmsResp['vLActivationInterval'])
|
||||||
loggerclt.info("KMS VL Renewal Interval: %s" % kmsResp['vLRenewalInterval'])
|
loggerclt.info("KMS VL Renewal Interval: %s" % kmsResp['vLRenewalInterval'])
|
||||||
loggerclt.mini("", extra = {'host': socket.gethostname() + " [" + clt_config["ip"] + "]",
|
|
||||||
'status' : "Activated",
|
if clt_config['loglevel'] == 'MINI':
|
||||||
'product' : clt_config["mode"]})
|
loggerclt.mini("", extra = {'host': socket.gethostname() + " [" + clt_config["ip"] + "]",
|
||||||
|
'status' : "Activated",
|
||||||
|
'product' : clt_config["mode"]})
|
||||||
|
|
||||||
ShellMessage.Process(21).run()
|
ShellMessage.Process(21).run()
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,11 @@ class ShellMessage(object):
|
||||||
# Do something with output.
|
# Do something with output.
|
||||||
toprint = self.read(0.1) # 0.1 s to let the shell output the result
|
toprint = self.read(0.1) # 0.1 s to let the shell output the result
|
||||||
# Redirect output.
|
# Redirect output.
|
||||||
from pykms_GuiBase import gui_redirect # Import after variables creation !
|
if sys.stdout.isatty():
|
||||||
gui_redirect(toprint)
|
print(toprint)
|
||||||
|
else:
|
||||||
|
from pykms_GuiBase import gui_redirect # Import after variables creation.
|
||||||
|
gui_redirect(toprint)
|
||||||
|
|
||||||
def spawn(self):
|
def spawn(self):
|
||||||
# Save everything that would otherwise go to stdout.
|
# Save everything that would otherwise go to stdout.
|
||||||
|
|
|
@ -50,7 +50,7 @@ def add_logging_level(levelName, levelNum, methodName = None):
|
||||||
|
|
||||||
class LevelFormatter(logging.Formatter):
|
class LevelFormatter(logging.Formatter):
|
||||||
dfmt = '%a, %d %b %Y %H:%M:%S'
|
dfmt = '%a, %d %b %Y %H:%M:%S'
|
||||||
default_fmt = logging.Formatter('[%(asctime)s] [%(levelname)8s] %(message)s', datefmt = dfmt)
|
default_fmt = logging.Formatter('%(message)s', datefmt = dfmt)
|
||||||
|
|
||||||
def __init__(self, formats):
|
def __init__(self, formats):
|
||||||
""" `formats` is a dict { loglevel : logformat } """
|
""" `formats` is a dict { loglevel : logformat } """
|
||||||
|
@ -81,8 +81,23 @@ def logger_create(log_obj, config, mode = 'a'):
|
||||||
backupCount = 1, encoding = None, delay = 0)
|
backupCount = 1, encoding = None, delay = 0)
|
||||||
|
|
||||||
log_handler.setLevel(config['loglevel'])
|
log_handler.setLevel(config['loglevel'])
|
||||||
|
|
||||||
# Configure formattation.
|
# Configure formattation.
|
||||||
formatter = LevelFormatter({logging.MINI : '[%(asctime)s] [%(levelname)8s] %(host)s %(status)s %(product)s %(message)s'})
|
try:
|
||||||
|
levelnames = logging._levelToName
|
||||||
|
except AttributeError:
|
||||||
|
levelnames = logging._levelNames
|
||||||
|
levelnum = [k for k in levelnames if k != 0]
|
||||||
|
form0 = '%(asctime)s %(levelname)-8s %(message)s'
|
||||||
|
form1 = '[%(asctime)s] [%(levelname)-8s] %(host)s %(status)s %(product)s %(message)s'
|
||||||
|
levelformdict = {}
|
||||||
|
for num in levelnum:
|
||||||
|
if num != logging.CRITICAL + 10:
|
||||||
|
levelformdict[num] = form0
|
||||||
|
else:
|
||||||
|
levelformdict[num] = form1
|
||||||
|
|
||||||
|
formatter = LevelFormatter(levelformdict)
|
||||||
log_handler.setFormatter(formatter)
|
log_handler.setFormatter(formatter)
|
||||||
# Attach.
|
# Attach.
|
||||||
log_obj.setLevel(config['loglevel'])
|
log_obj.setLevel(config['loglevel'])
|
||||||
|
|
|
@ -180,7 +180,7 @@ def server_create():
|
||||||
socketserver.TCPServer.allow_reuse_address = True
|
socketserver.TCPServer.allow_reuse_address = True
|
||||||
server = socketserver.TCPServer((srv_config['ip'], srv_config['port']), kmsServer)
|
server = socketserver.TCPServer((srv_config['ip'], srv_config['port']), kmsServer)
|
||||||
server.timeout = srv_config['timeout']
|
server.timeout = srv_config['timeout']
|
||||||
loggersrv.info("\n\nTCP server listening at %s on port %d." % (srv_config['ip'], srv_config['port']))
|
loggersrv.info("TCP server listening at %s on port %d." % (srv_config['ip'], srv_config['port']))
|
||||||
loggersrv.info("HWID: %s" % deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper())
|
loggersrv.info("HWID: %s" % deco(binascii.b2a_hex(srv_config['hwid']), 'utf-8').upper())
|
||||||
return server
|
return server
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue