From 1148fe804f3e6b77558812ee6723a1f8a5427f12 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 16 Oct 2022 12:28:46 +0800 Subject: [PATCH] update: file structure --- src/aidusk.com/logger.py | 47 ------------------ src/{ => crawler}/108shu.com/catalog.py | 0 src/{ => crawler}/108shu.com/crawler.sh | 0 src/{ => crawler}/108shu.com/extract.py | 0 src/{ => crawler}/108shu.com/fetch.py | 0 .../aidusk.com/archive/catalog.json.xz | Bin .../aidusk.com/archive/html.tar.xz | Bin .../aidusk.com/archive/xxrs.json.xz | Bin src/{ => crawler}/aidusk.com/catalog.py | 0 src/{ => crawler}/aidusk.com/check.sh | 0 src/{ => crawler}/aidusk.com/crawler.sh | 0 src/{ => crawler}/aidusk.com/extract.py | 0 src/{ => crawler}/aidusk.com/fetch.py | 0 .../ixsw.la/archive/catalog.json.xz | Bin src/{ => crawler}/ixsw.la/archive/html.tar.xz | Bin .../ixsw.la/archive/xxrs.json.xz | Bin src/{ => crawler}/ixsw.la/catalog.py | 0 src/{ => crawler}/ixsw.la/check.sh | 0 src/{ => crawler}/ixsw.la/crawler.sh | 0 src/{ => crawler}/ixsw.la/extract.py | 0 src/{ => crawler}/ixsw.la/fetch.py | 0 src/{108shu.com => crawler}/logger.py | 0 .../m.wxsy.net/archive/catalog.json.xz | Bin .../m.wxsy.net/archive/html.tar.xz | Bin .../m.wxsy.net/archive/json.sha1sum | 0 .../m.wxsy.net/archive/json.tar.xz | Bin .../m.wxsy.net/archive/xxrs.json.xz | Bin src/{ => crawler}/m.wxsy.net/catalog.py | 4 +- src/{ => crawler}/m.wxsy.net/check.sh | 0 src/{ => crawler}/m.wxsy.net/crawler.sh | 0 src/{ => crawler}/m.wxsy.net/extract.py | 0 src/{ => crawler}/m.wxsy.net/fetch.py | 0 src/{ => crawler}/m.wxsy.net/release.py | 0 .../wxsy.net/archive/catalog.json.xz | Bin .../wxsy.net/archive/html.tar.xz | Bin .../wxsy.net/archive/json.sha1sum | 0 .../wxsy.net/archive/json.tar.xz | Bin .../wxsy.net/archive/xxrs.json.xz | Bin src/{ => crawler}/wxsy.net/catalog.py | 0 src/{ => crawler}/wxsy.net/check.sh | 0 src/{ => crawler}/wxsy.net/crawler.sh | 0 src/{ => crawler}/wxsy.net/extract.py | 0 src/{ => crawler}/wxsy.net/fetch.py | 0 src/{ => crawler}/wxsy.net/release.py | 0 src/{ => crawler}/xswang.com/catalog.py | 0 src/{ => crawler}/xswang.com/crawler.sh | 0 src/{ => crawler}/xswang.com/extract.py | 0 src/{ => crawler}/xswang.com/fetch.py | 0 src/ixsw.la/logger.py | 47 ------------------ src/m.wxsy.net/logger.py | 47 ------------------ src/wxsy.net/logger.py | 47 ------------------ src/xswang.com/logger.py | 47 ------------------ 52 files changed, 3 insertions(+), 236 deletions(-) delete mode 100644 src/aidusk.com/logger.py rename src/{ => crawler}/108shu.com/catalog.py (100%) rename src/{ => crawler}/108shu.com/crawler.sh (100%) rename src/{ => crawler}/108shu.com/extract.py (100%) rename src/{ => crawler}/108shu.com/fetch.py (100%) rename src/{ => crawler}/aidusk.com/archive/catalog.json.xz (100%) rename src/{ => crawler}/aidusk.com/archive/html.tar.xz (100%) rename src/{ => crawler}/aidusk.com/archive/xxrs.json.xz (100%) rename src/{ => crawler}/aidusk.com/catalog.py (100%) rename src/{ => crawler}/aidusk.com/check.sh (100%) rename src/{ => crawler}/aidusk.com/crawler.sh (100%) rename src/{ => crawler}/aidusk.com/extract.py (100%) rename src/{ => crawler}/aidusk.com/fetch.py (100%) rename src/{ => crawler}/ixsw.la/archive/catalog.json.xz (100%) rename src/{ => crawler}/ixsw.la/archive/html.tar.xz (100%) rename src/{ => crawler}/ixsw.la/archive/xxrs.json.xz (100%) rename src/{ => crawler}/ixsw.la/catalog.py (100%) rename src/{ => crawler}/ixsw.la/check.sh (100%) rename src/{ => crawler}/ixsw.la/crawler.sh (100%) rename src/{ => crawler}/ixsw.la/extract.py (100%) rename src/{ => crawler}/ixsw.la/fetch.py (100%) rename src/{108shu.com => crawler}/logger.py (100%) rename src/{ => crawler}/m.wxsy.net/archive/catalog.json.xz (100%) rename src/{ => crawler}/m.wxsy.net/archive/html.tar.xz (100%) rename src/{ => crawler}/m.wxsy.net/archive/json.sha1sum (100%) rename src/{ => crawler}/m.wxsy.net/archive/json.tar.xz (100%) rename src/{ => crawler}/m.wxsy.net/archive/xxrs.json.xz (100%) rename src/{ => crawler}/m.wxsy.net/catalog.py (99%) rename src/{ => crawler}/m.wxsy.net/check.sh (100%) rename src/{ => crawler}/m.wxsy.net/crawler.sh (100%) rename src/{ => crawler}/m.wxsy.net/extract.py (100%) rename src/{ => crawler}/m.wxsy.net/fetch.py (100%) rename src/{ => crawler}/m.wxsy.net/release.py (100%) rename src/{ => crawler}/wxsy.net/archive/catalog.json.xz (100%) rename src/{ => crawler}/wxsy.net/archive/html.tar.xz (100%) rename src/{ => crawler}/wxsy.net/archive/json.sha1sum (100%) rename src/{ => crawler}/wxsy.net/archive/json.tar.xz (100%) rename src/{ => crawler}/wxsy.net/archive/xxrs.json.xz (100%) rename src/{ => crawler}/wxsy.net/catalog.py (100%) rename src/{ => crawler}/wxsy.net/check.sh (100%) rename src/{ => crawler}/wxsy.net/crawler.sh (100%) rename src/{ => crawler}/wxsy.net/extract.py (100%) rename src/{ => crawler}/wxsy.net/fetch.py (100%) rename src/{ => crawler}/wxsy.net/release.py (100%) rename src/{ => crawler}/xswang.com/catalog.py (100%) rename src/{ => crawler}/xswang.com/crawler.sh (100%) rename src/{ => crawler}/xswang.com/extract.py (100%) rename src/{ => crawler}/xswang.com/fetch.py (100%) delete mode 100644 src/ixsw.la/logger.py delete mode 100644 src/m.wxsy.net/logger.py delete mode 100644 src/wxsy.net/logger.py delete mode 100644 src/xswang.com/logger.py diff --git a/src/aidusk.com/logger.py b/src/aidusk.com/logger.py deleted file mode 100644 index 36cfaf8..0000000 --- a/src/aidusk.com/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Logger module: - INFO level -> stderr - DEBUG level -> runtime.log -""" - -import sys -import logging -import colorlog - -logColor = { # log color - 'DEBUG': 'white', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'bold_red', -} - -dateFormat = '%Y-%m-%d %H:%M:%S' -timeFormat = '%(asctime)s.%(msecs)03d' -logFormat = '[%(levelname)s] %(message)s (%(module)s.%(funcName)s:%(lineno)d)' - -# load fileHandler -> log file -fileHandler = logging.FileHandler('runtime.log', encoding = 'utf-8') -fileHandler.setFormatter(logging.Formatter( - '[' + timeFormat + '] ' + logFormat, - datefmt = dateFormat -)) -fileHandler.setLevel(logging.DEBUG) # debug level for log file - -# load stdHandler -> stderr -stdHandler = colorlog.StreamHandler() -stdHandler.setFormatter(colorlog.ColoredFormatter( - '%(light_black)s' + timeFormat + '%(log_color)s ' + logFormat, - datefmt = dateFormat, - log_colors = logColor, - stream = sys.stderr -)) -stdHandler.setLevel(logging.INFO) # info level for stderr - -logger = logging.getLogger() -logger.addHandler(stdHandler) -logger.addHandler(fileHandler) -logger.setLevel(logging.DEBUG) # set log level in handler diff --git a/src/108shu.com/catalog.py b/src/crawler/108shu.com/catalog.py similarity index 100% rename from src/108shu.com/catalog.py rename to src/crawler/108shu.com/catalog.py diff --git a/src/108shu.com/crawler.sh b/src/crawler/108shu.com/crawler.sh similarity index 100% rename from src/108shu.com/crawler.sh rename to src/crawler/108shu.com/crawler.sh diff --git a/src/108shu.com/extract.py b/src/crawler/108shu.com/extract.py similarity index 100% rename from src/108shu.com/extract.py rename to src/crawler/108shu.com/extract.py diff --git a/src/108shu.com/fetch.py b/src/crawler/108shu.com/fetch.py similarity index 100% rename from src/108shu.com/fetch.py rename to src/crawler/108shu.com/fetch.py diff --git a/src/aidusk.com/archive/catalog.json.xz b/src/crawler/aidusk.com/archive/catalog.json.xz similarity index 100% rename from src/aidusk.com/archive/catalog.json.xz rename to src/crawler/aidusk.com/archive/catalog.json.xz diff --git a/src/aidusk.com/archive/html.tar.xz b/src/crawler/aidusk.com/archive/html.tar.xz similarity index 100% rename from src/aidusk.com/archive/html.tar.xz rename to src/crawler/aidusk.com/archive/html.tar.xz diff --git a/src/aidusk.com/archive/xxrs.json.xz b/src/crawler/aidusk.com/archive/xxrs.json.xz similarity index 100% rename from src/aidusk.com/archive/xxrs.json.xz rename to src/crawler/aidusk.com/archive/xxrs.json.xz diff --git a/src/aidusk.com/catalog.py b/src/crawler/aidusk.com/catalog.py similarity index 100% rename from src/aidusk.com/catalog.py rename to src/crawler/aidusk.com/catalog.py diff --git a/src/aidusk.com/check.sh b/src/crawler/aidusk.com/check.sh similarity index 100% rename from src/aidusk.com/check.sh rename to src/crawler/aidusk.com/check.sh diff --git a/src/aidusk.com/crawler.sh b/src/crawler/aidusk.com/crawler.sh similarity index 100% rename from src/aidusk.com/crawler.sh rename to src/crawler/aidusk.com/crawler.sh diff --git a/src/aidusk.com/extract.py b/src/crawler/aidusk.com/extract.py similarity index 100% rename from src/aidusk.com/extract.py rename to src/crawler/aidusk.com/extract.py diff --git a/src/aidusk.com/fetch.py b/src/crawler/aidusk.com/fetch.py similarity index 100% rename from src/aidusk.com/fetch.py rename to src/crawler/aidusk.com/fetch.py diff --git a/src/ixsw.la/archive/catalog.json.xz b/src/crawler/ixsw.la/archive/catalog.json.xz similarity index 100% rename from src/ixsw.la/archive/catalog.json.xz rename to src/crawler/ixsw.la/archive/catalog.json.xz diff --git a/src/ixsw.la/archive/html.tar.xz b/src/crawler/ixsw.la/archive/html.tar.xz similarity index 100% rename from src/ixsw.la/archive/html.tar.xz rename to src/crawler/ixsw.la/archive/html.tar.xz diff --git a/src/ixsw.la/archive/xxrs.json.xz b/src/crawler/ixsw.la/archive/xxrs.json.xz similarity index 100% rename from src/ixsw.la/archive/xxrs.json.xz rename to src/crawler/ixsw.la/archive/xxrs.json.xz diff --git a/src/ixsw.la/catalog.py b/src/crawler/ixsw.la/catalog.py similarity index 100% rename from src/ixsw.la/catalog.py rename to src/crawler/ixsw.la/catalog.py diff --git a/src/ixsw.la/check.sh b/src/crawler/ixsw.la/check.sh similarity index 100% rename from src/ixsw.la/check.sh rename to src/crawler/ixsw.la/check.sh diff --git a/src/ixsw.la/crawler.sh b/src/crawler/ixsw.la/crawler.sh similarity index 100% rename from src/ixsw.la/crawler.sh rename to src/crawler/ixsw.la/crawler.sh diff --git a/src/ixsw.la/extract.py b/src/crawler/ixsw.la/extract.py similarity index 100% rename from src/ixsw.la/extract.py rename to src/crawler/ixsw.la/extract.py diff --git a/src/ixsw.la/fetch.py b/src/crawler/ixsw.la/fetch.py similarity index 100% rename from src/ixsw.la/fetch.py rename to src/crawler/ixsw.la/fetch.py diff --git a/src/108shu.com/logger.py b/src/crawler/logger.py similarity index 100% rename from src/108shu.com/logger.py rename to src/crawler/logger.py diff --git a/src/m.wxsy.net/archive/catalog.json.xz b/src/crawler/m.wxsy.net/archive/catalog.json.xz similarity index 100% rename from src/m.wxsy.net/archive/catalog.json.xz rename to src/crawler/m.wxsy.net/archive/catalog.json.xz diff --git a/src/m.wxsy.net/archive/html.tar.xz b/src/crawler/m.wxsy.net/archive/html.tar.xz similarity index 100% rename from src/m.wxsy.net/archive/html.tar.xz rename to src/crawler/m.wxsy.net/archive/html.tar.xz diff --git a/src/m.wxsy.net/archive/json.sha1sum b/src/crawler/m.wxsy.net/archive/json.sha1sum similarity index 100% rename from src/m.wxsy.net/archive/json.sha1sum rename to src/crawler/m.wxsy.net/archive/json.sha1sum diff --git a/src/m.wxsy.net/archive/json.tar.xz b/src/crawler/m.wxsy.net/archive/json.tar.xz similarity index 100% rename from src/m.wxsy.net/archive/json.tar.xz rename to src/crawler/m.wxsy.net/archive/json.tar.xz diff --git a/src/m.wxsy.net/archive/xxrs.json.xz b/src/crawler/m.wxsy.net/archive/xxrs.json.xz similarity index 100% rename from src/m.wxsy.net/archive/xxrs.json.xz rename to src/crawler/m.wxsy.net/archive/xxrs.json.xz diff --git a/src/m.wxsy.net/catalog.py b/src/crawler/m.wxsy.net/catalog.py similarity index 99% rename from src/m.wxsy.net/catalog.py rename to src/crawler/m.wxsy.net/catalog.py index 8830c8e..1028536 100644 --- a/src/m.wxsy.net/catalog.py +++ b/src/crawler/m.wxsy.net/catalog.py @@ -7,8 +7,10 @@ Fetch catalog and output as JSON format. USAGE: python3 catalog.py """ -import re import sys +sys.path.append('..') + +import re import json import time import requests diff --git a/src/m.wxsy.net/check.sh b/src/crawler/m.wxsy.net/check.sh similarity index 100% rename from src/m.wxsy.net/check.sh rename to src/crawler/m.wxsy.net/check.sh diff --git a/src/m.wxsy.net/crawler.sh b/src/crawler/m.wxsy.net/crawler.sh similarity index 100% rename from src/m.wxsy.net/crawler.sh rename to src/crawler/m.wxsy.net/crawler.sh diff --git a/src/m.wxsy.net/extract.py b/src/crawler/m.wxsy.net/extract.py similarity index 100% rename from src/m.wxsy.net/extract.py rename to src/crawler/m.wxsy.net/extract.py diff --git a/src/m.wxsy.net/fetch.py b/src/crawler/m.wxsy.net/fetch.py similarity index 100% rename from src/m.wxsy.net/fetch.py rename to src/crawler/m.wxsy.net/fetch.py diff --git a/src/m.wxsy.net/release.py b/src/crawler/m.wxsy.net/release.py similarity index 100% rename from src/m.wxsy.net/release.py rename to src/crawler/m.wxsy.net/release.py diff --git a/src/wxsy.net/archive/catalog.json.xz b/src/crawler/wxsy.net/archive/catalog.json.xz similarity index 100% rename from src/wxsy.net/archive/catalog.json.xz rename to src/crawler/wxsy.net/archive/catalog.json.xz diff --git a/src/wxsy.net/archive/html.tar.xz b/src/crawler/wxsy.net/archive/html.tar.xz similarity index 100% rename from src/wxsy.net/archive/html.tar.xz rename to src/crawler/wxsy.net/archive/html.tar.xz diff --git a/src/wxsy.net/archive/json.sha1sum b/src/crawler/wxsy.net/archive/json.sha1sum similarity index 100% rename from src/wxsy.net/archive/json.sha1sum rename to src/crawler/wxsy.net/archive/json.sha1sum diff --git a/src/wxsy.net/archive/json.tar.xz b/src/crawler/wxsy.net/archive/json.tar.xz similarity index 100% rename from src/wxsy.net/archive/json.tar.xz rename to src/crawler/wxsy.net/archive/json.tar.xz diff --git a/src/wxsy.net/archive/xxrs.json.xz b/src/crawler/wxsy.net/archive/xxrs.json.xz similarity index 100% rename from src/wxsy.net/archive/xxrs.json.xz rename to src/crawler/wxsy.net/archive/xxrs.json.xz diff --git a/src/wxsy.net/catalog.py b/src/crawler/wxsy.net/catalog.py similarity index 100% rename from src/wxsy.net/catalog.py rename to src/crawler/wxsy.net/catalog.py diff --git a/src/wxsy.net/check.sh b/src/crawler/wxsy.net/check.sh similarity index 100% rename from src/wxsy.net/check.sh rename to src/crawler/wxsy.net/check.sh diff --git a/src/wxsy.net/crawler.sh b/src/crawler/wxsy.net/crawler.sh similarity index 100% rename from src/wxsy.net/crawler.sh rename to src/crawler/wxsy.net/crawler.sh diff --git a/src/wxsy.net/extract.py b/src/crawler/wxsy.net/extract.py similarity index 100% rename from src/wxsy.net/extract.py rename to src/crawler/wxsy.net/extract.py diff --git a/src/wxsy.net/fetch.py b/src/crawler/wxsy.net/fetch.py similarity index 100% rename from src/wxsy.net/fetch.py rename to src/crawler/wxsy.net/fetch.py diff --git a/src/wxsy.net/release.py b/src/crawler/wxsy.net/release.py similarity index 100% rename from src/wxsy.net/release.py rename to src/crawler/wxsy.net/release.py diff --git a/src/xswang.com/catalog.py b/src/crawler/xswang.com/catalog.py similarity index 100% rename from src/xswang.com/catalog.py rename to src/crawler/xswang.com/catalog.py diff --git a/src/xswang.com/crawler.sh b/src/crawler/xswang.com/crawler.sh similarity index 100% rename from src/xswang.com/crawler.sh rename to src/crawler/xswang.com/crawler.sh diff --git a/src/xswang.com/extract.py b/src/crawler/xswang.com/extract.py similarity index 100% rename from src/xswang.com/extract.py rename to src/crawler/xswang.com/extract.py diff --git a/src/xswang.com/fetch.py b/src/crawler/xswang.com/fetch.py similarity index 100% rename from src/xswang.com/fetch.py rename to src/crawler/xswang.com/fetch.py diff --git a/src/ixsw.la/logger.py b/src/ixsw.la/logger.py deleted file mode 100644 index 36cfaf8..0000000 --- a/src/ixsw.la/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Logger module: - INFO level -> stderr - DEBUG level -> runtime.log -""" - -import sys -import logging -import colorlog - -logColor = { # log color - 'DEBUG': 'white', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'bold_red', -} - -dateFormat = '%Y-%m-%d %H:%M:%S' -timeFormat = '%(asctime)s.%(msecs)03d' -logFormat = '[%(levelname)s] %(message)s (%(module)s.%(funcName)s:%(lineno)d)' - -# load fileHandler -> log file -fileHandler = logging.FileHandler('runtime.log', encoding = 'utf-8') -fileHandler.setFormatter(logging.Formatter( - '[' + timeFormat + '] ' + logFormat, - datefmt = dateFormat -)) -fileHandler.setLevel(logging.DEBUG) # debug level for log file - -# load stdHandler -> stderr -stdHandler = colorlog.StreamHandler() -stdHandler.setFormatter(colorlog.ColoredFormatter( - '%(light_black)s' + timeFormat + '%(log_color)s ' + logFormat, - datefmt = dateFormat, - log_colors = logColor, - stream = sys.stderr -)) -stdHandler.setLevel(logging.INFO) # info level for stderr - -logger = logging.getLogger() -logger.addHandler(stdHandler) -logger.addHandler(fileHandler) -logger.setLevel(logging.DEBUG) # set log level in handler diff --git a/src/m.wxsy.net/logger.py b/src/m.wxsy.net/logger.py deleted file mode 100644 index 36cfaf8..0000000 --- a/src/m.wxsy.net/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Logger module: - INFO level -> stderr - DEBUG level -> runtime.log -""" - -import sys -import logging -import colorlog - -logColor = { # log color - 'DEBUG': 'white', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'bold_red', -} - -dateFormat = '%Y-%m-%d %H:%M:%S' -timeFormat = '%(asctime)s.%(msecs)03d' -logFormat = '[%(levelname)s] %(message)s (%(module)s.%(funcName)s:%(lineno)d)' - -# load fileHandler -> log file -fileHandler = logging.FileHandler('runtime.log', encoding = 'utf-8') -fileHandler.setFormatter(logging.Formatter( - '[' + timeFormat + '] ' + logFormat, - datefmt = dateFormat -)) -fileHandler.setLevel(logging.DEBUG) # debug level for log file - -# load stdHandler -> stderr -stdHandler = colorlog.StreamHandler() -stdHandler.setFormatter(colorlog.ColoredFormatter( - '%(light_black)s' + timeFormat + '%(log_color)s ' + logFormat, - datefmt = dateFormat, - log_colors = logColor, - stream = sys.stderr -)) -stdHandler.setLevel(logging.INFO) # info level for stderr - -logger = logging.getLogger() -logger.addHandler(stdHandler) -logger.addHandler(fileHandler) -logger.setLevel(logging.DEBUG) # set log level in handler diff --git a/src/wxsy.net/logger.py b/src/wxsy.net/logger.py deleted file mode 100644 index 36cfaf8..0000000 --- a/src/wxsy.net/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Logger module: - INFO level -> stderr - DEBUG level -> runtime.log -""" - -import sys -import logging -import colorlog - -logColor = { # log color - 'DEBUG': 'white', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'bold_red', -} - -dateFormat = '%Y-%m-%d %H:%M:%S' -timeFormat = '%(asctime)s.%(msecs)03d' -logFormat = '[%(levelname)s] %(message)s (%(module)s.%(funcName)s:%(lineno)d)' - -# load fileHandler -> log file -fileHandler = logging.FileHandler('runtime.log', encoding = 'utf-8') -fileHandler.setFormatter(logging.Formatter( - '[' + timeFormat + '] ' + logFormat, - datefmt = dateFormat -)) -fileHandler.setLevel(logging.DEBUG) # debug level for log file - -# load stdHandler -> stderr -stdHandler = colorlog.StreamHandler() -stdHandler.setFormatter(colorlog.ColoredFormatter( - '%(light_black)s' + timeFormat + '%(log_color)s ' + logFormat, - datefmt = dateFormat, - log_colors = logColor, - stream = sys.stderr -)) -stdHandler.setLevel(logging.INFO) # info level for stderr - -logger = logging.getLogger() -logger.addHandler(stdHandler) -logger.addHandler(fileHandler) -logger.setLevel(logging.DEBUG) # set log level in handler diff --git a/src/xswang.com/logger.py b/src/xswang.com/logger.py deleted file mode 100644 index 36cfaf8..0000000 --- a/src/xswang.com/logger.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Logger module: - INFO level -> stderr - DEBUG level -> runtime.log -""" - -import sys -import logging -import colorlog - -logColor = { # log color - 'DEBUG': 'white', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'bold_red', -} - -dateFormat = '%Y-%m-%d %H:%M:%S' -timeFormat = '%(asctime)s.%(msecs)03d' -logFormat = '[%(levelname)s] %(message)s (%(module)s.%(funcName)s:%(lineno)d)' - -# load fileHandler -> log file -fileHandler = logging.FileHandler('runtime.log', encoding = 'utf-8') -fileHandler.setFormatter(logging.Formatter( - '[' + timeFormat + '] ' + logFormat, - datefmt = dateFormat -)) -fileHandler.setLevel(logging.DEBUG) # debug level for log file - -# load stdHandler -> stderr -stdHandler = colorlog.StreamHandler() -stdHandler.setFormatter(colorlog.ColoredFormatter( - '%(light_black)s' + timeFormat + '%(log_color)s ' + logFormat, - datefmt = dateFormat, - log_colors = logColor, - stream = sys.stderr -)) -stdHandler.setLevel(logging.INFO) # info level for stderr - -logger = logging.getLogger() -logger.addHandler(stdHandler) -logger.addHandler(fileHandler) -logger.setLevel(logging.DEBUG) # set log level in handler