Skip to content

Commit

Permalink
Merge pull request #387 from AngusWG/master
Browse files Browse the repository at this point in the history
Fix Logger initialization time too long
  • Loading branch information
Cuizi7 committed Oct 27, 2018
2 parents 018fe08 + a6b8539 commit 2c343ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ line-profiler>=2.0
PyYAML>=3.12

tabulate
colorama>=0.3.9
12 changes: 5 additions & 7 deletions rqalpha/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,27 +201,25 @@ def list(params):
"""
List all mod configuration
"""
from colorama import init, Fore
from tabulate import tabulate
from rqalpha.utils.config import get_mod_conf
init()

mod_config = get_mod_conf()
table = []

for mod_name, mod in six.iteritems(mod_config['mod']):
table.append([
Fore.RESET + mod_name,
(Fore.GREEN + "enabled" if mod['enabled'] else Fore.RED + "disabled") + Fore.RESET
mod_name,
("enabled" if mod['enabled'] else "disabled")
])

headers = [
Fore.CYAN + "name",
Fore.CYAN + "status" + Fore.RESET
"name",
"status"
]

six.print_(tabulate(table, headers=headers, tablefmt="psql"))
six.print_(Fore.LIGHTYELLOW_EX + "You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods")
six.print_("You can use `rqalpha mod list/install/uninstall/enable/disable` to manage your mods")

def install(params):
"""
Expand Down
13 changes: 6 additions & 7 deletions rqalpha/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

from datetime import datetime
import logbook
from logbook import Logger
from logbook.more import ColorizedStderrHandler
from logbook import Logger, StderrHandler

from rqalpha.utils.py2 import to_utf8, from_utf8

Expand Down Expand Up @@ -52,7 +51,7 @@ def user_std_handler_log_formatter(record, handler):
return log


user_std_handler = ColorizedStderrHandler(bubble=True)
user_std_handler = StderrHandler(bubble=True)
user_std_handler.formatter = user_std_handler_log_formatter


Expand Down Expand Up @@ -80,7 +79,7 @@ def formatter(record, handler):

# 用于用户异常的详细日志打印
user_detail_log = Logger("user_detail_log")
# user_detail_log.handlers.append(ColorizedStderrHandler(bubble=True))
# user_detail_log.handlers.append(StderrHandler(bubble=True))

# 系统日志
system_log = Logger("system_log")
Expand All @@ -91,9 +90,9 @@ def formatter(record, handler):


def init_logger():
system_log.handlers = [ColorizedStderrHandler(bubble=True)]
basic_system_log.handlers = [ColorizedStderrHandler(bubble=True)]
std_log.handlers = [ColorizedStderrHandler(bubble=True)]
system_log.handlers = [StderrHandler(bubble=True)]
basic_system_log.handlers = [StderrHandler(bubble=True)]
std_log.handlers = [StderrHandler(bubble=True)]
user_log.handlers = []
user_system_log.handlers = []

Expand Down

0 comments on commit 2c343ca

Please sign in to comment.