From cc2bcfe935570a9d642d443d58ae702a171aae9c Mon Sep 17 00:00:00 2001 From: xuezhixin Date: Mon, 4 Nov 2024 09:49:51 +0800 Subject: [PATCH] add loger interface function --- 0006-add-loger-interface-function.patc | 58 ++++++++++++++++++++++++++ migration-tools.spec | 6 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 0006-add-loger-interface-function.patc diff --git a/0006-add-loger-interface-function.patc b/0006-add-loger-interface-function.patc new file mode 100644 index 0000000..6bc11de --- /dev/null +++ b/0006-add-loger-interface-function.patc @@ -0,0 +1,58 @@ +From 0d0a26ccedd820a583e4579d240542e346e459f3 Mon Sep 17 00:00:00 2001 +From: lixin +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 + diff --git a/migration-tools.spec b/migration-tools.spec index 9e36c23..66af264 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,6 +1,6 @@ Name: migration-tools Version: 1.0.2 -Release: 5 +Release: 6 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: %{name}-%{version}.tar.gz @@ -12,6 +12,7 @@ Patch1: 0002-modify-excel-report-content.patch Patch2: 0003-delete-redundant-code.patch Patch3: 0004-connect-sql-function.patch Patch4: 0005-execution-sql-function.patch +Patch5: 0006-add-loger-interface-function.patc BuildArch: noarch BuildRequires: systemd @@ -110,6 +111,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Mon Nov 4 2024 xuezhixin - 1.0.2-6 +- 0006-add-loger-interface-function.patc + * Fri Nov 1 2024 xuezhixin - 1.0.2-5 - add 0005-execution-sql-function.patch