From 0d0a26ccedd820a583e4579d240542e346e459f3 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Tue, 7 Nov 2023 11:05:17 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97=E5=8A=9F?=
 =?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 logger.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 logger.py

diff --git a/logger.py b/logger.py
new file mode 100644
index 0000000..2bdd144
--- /dev/null
+++ b/logger.py
@@ -0,0 +1,34 @@
+# -*-coding:UTF-8-*-
+
+import logging
+
+class Logger:
+    def __init__(self, path,clevel = logging.DEBUG,Flevel = logging.DEBUG):
+        self.logger = logging.getLogger(path)
+        self.logger.setLevel(logging.DEBUG)
+        fmt = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s', '%Y-%m-%d %H:%M:%S')
+        #设置CMD日志
+        sh = logging.StreamHandler()
+        sh.setFormatter(fmt)
+        sh.setLevel(clevel)
+        #设置文件日志
+        fh = logging.FileHandler(path)
+        fh.setFormatter(fmt)
+        fh.setLevel(Flevel)
+        self.logger.addHandler(sh)
+        self.logger.addHandler(fh)
+
+    def debug(self,message):
+        self.logger.debug(message)
+
+    def info(self,message):
+        self.logger.info(message)
+
+    def war(self,message):
+        self.logger.warning(message)
+
+    def error(self,message):
+        self.logger.error(message)
+
+    def cri(self,message):
+        self.logger.critical(message)
\ No newline at end of file
-- 
2.20.1

