Skip to content

Commit

Permalink
Merge pull request ctpbee#148 from ctpbee/master
Browse files Browse the repository at this point in the history
update color
  • Loading branch information
somewheve authored Jun 5, 2021
2 parents 08261ad + a72fe89 commit 896314e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 91 deletions.
14 changes: 2 additions & 12 deletions ctpbee/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ctpbee.constant import Event, EVENT_TIMER
from ctpbee.constant import Exchange
from ctpbee.context import _app_context_ctx
from ctpbee.cprint_config import CP
from ctpbee.exceptions import ConfigError
from ctpbee.helpers import end_thread
from ctpbee.helpers import find_package, refresh_query, graphic_pattern
Expand Down Expand Up @@ -67,7 +66,6 @@ def __init__(self,
import_name,
action_class: Action or None = None,
engine_method: str = "thread",
logger_class=None, logger_config=None,
refresh: bool = True,
risk: RiskLevel = None,
instance_path=None):
Expand All @@ -89,16 +87,8 @@ def __init__(self,
self.engine_method = engine_method
self.refresh = refresh
self.active = False
# 是否加载以使用默认的logger类/ choose if use the default logging class
if logger_class is None:
self.logger = VLogger(CP, app_name=self.name)
self.logger.set_default(name=self.logger.app_name, owner=self.name)
else:
if logger_config:
self.logger = logger_class(logger_config, app_name=self.name)
else:
self.logger = logger_class(CP, app_name=self.name)
self.logger.set_default(name=self.logger.app_name, owner='App')
self.logger = VLogger
self.logger.set_field_default(name=self.name, owner=self.name)

self.app_signal = AppSignal(self.name)

Expand Down
67 changes: 0 additions & 67 deletions ctpbee/cprint_config.py

This file was deleted.

50 changes: 39 additions & 11 deletions ctpbee/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from colour_printing.custom import PrintMe

VLogger = PrintMe
"""
实现一个默认的LoggerClass<<<<<<< dev
Expand All @@ -9,14 +6,45 @@
时间 ---- 执行者 ---- 等级 ---- 信息
"""
from cologer import loger,Fore,Back,Style

if __name__ == '__main__':
from ctpbee.cprint_config import CP
loger.set_format('{time} {name} {level} {owner} {message}')
# info
loger.info.fields.time.set_fore(Fore.RED)
loger.info.fields.name
loger.info.fields.level.set_fore(Fore.MAGENTA)
loger.info.fields.owner.set_fore(Fore.CYAN)
loger.info.fields.message.set_fore(Fore.GREEN)
# success
loger.success.fields.time.set_fore(Fore.CYAN)
loger.success.fields.name.set_fore(Fore.CYAN)
loger.success.fields.level
loger.success.fields.owner.set_fore(Fore.CYAN)
loger.success.fields.message.set_fore(Fore.CYAN)
# warning
loger.warning.fields.time.set_fore(Fore.RED)
loger.warning.fields.name
loger.warning.fields.level.set_fore(Fore.MAGENTA)
loger.warning.fields.owner.set_fore(Fore.CYAN)
loger.warning.fields.message.set_fore(Fore.YELLOW)
# error
loger.error.fields.time.set_fore(Fore.RED)
loger.error.fields.name
loger.error.fields.level.set_fore(Fore.MAGENTA)
loger.error.fields.owner.set_fore(Fore.CYAN)
loger.error.fields.message.set_fore(Fore.RED)
# debug
loger.debug.fields.time.set_fore(Fore.RED)
loger.debug.fields.name
loger.debug.fields.level.set_fore(Fore.MAGENTA)
loger.debug.fields.owner.set_fore(Fore.CYAN)
loger.debug.fields.message.set_fore(Fore.MAGENTA)

logger_me = VLogger(CP)
VLogger = loger

# logger_me.set_formatter("handler")
logger_me.warning("这里发生了警告", owner="somewheve")
logger_me.error("这里发生了错误", owner="somewheve")
logger_me.info("这里发生了信息输出", owner="somewheve")
logger_me.debug("这里发生了调试", owner="somewheve")
if __name__ == '__main__':
loger.warning("这里发生了警告", owner="somewheve")
loger.success("这里发生了成功", owner="somewheve")
loger.error("这里发生了错误", owner="somewheve")
loger.info("这里发生了信息输出", owner="somewheve")
loger.debug("这里发生了调试", owner="somewheve")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# libraries
install_requires = ["pytz", "blinker", "requests", "simplejson", "lxml",
'colour_printing>=0.3.16', "ctpbee_api", "numpy"]
'cologer', "ctpbee_api", "numpy"]

if sys.version_info.major == 3 and sys.version_info.minor == 6:
install_requires.append("dataclasses")
Expand Down

0 comments on commit 896314e

Please sign in to comment.