From 9fa1b54b998f7d7f685b7fae1fef3aa694c81d14 Mon Sep 17 00:00:00 2001 From: Bigsk Date: Wed, 18 Nov 2020 15:38:23 +0800 Subject: [PATCH] Small update for log functiom --- main.py => core.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename main.py => core.py (95%) diff --git a/main.py b/core.py similarity index 95% rename from main.py rename to core.py index 78fceed..d5f6638 100644 --- a/main.py +++ b/core.py @@ -36,10 +36,12 @@ class GMCLCore(object): self.__LogOutput=LogOutput self.__UserAgent={'User-Agent':LauncherName+'/'+LauncherVersion+' ((GMCL Core Alpha 0.2.0;Alpha))'} self.__Log=[] - def Log(self,Type,Text,Function="Anonymous Function"): + def Log(self,Type,Text,Function="Anonymous Function",ErrorType="TypeError"): '''The function which was used to manager the log output system''' ''':Type Type of the log info''' ''':Text The main text of log info''' + ''':Function The function that cause the log,the default value is "Anonymous Function"''' + ''':Type The type of the error,the default value is "TypeError"''' if(Text!="" or None): if(Type=="info"): self.__Log.append(("INFO",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),Function,Text)) @@ -48,8 +50,8 @@ class GMCLCore(object): self.__Log.append(("WARN",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),Function,Text)) return ("WARN",Text) elif(Type=="error"): - self.__Log.append(("ERROR",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),Function,Text)) - return ("ERROR",Text) + self.__Log.append(("ERROR",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),Function,Text,ErrorType)) + raise TypeError(Text) else: self.__Log.append(("OTHER",time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),Function,Text)) return ("OTHER",Text)