Skip to content
This repository has been archived by the owner on Apr 13, 2018. It is now read-only.

Commit

Permalink
增加 --verbose 启动选项,支持在屏幕中直接打印 log
Browse files Browse the repository at this point in the history
  • Loading branch information
wzpan committed Dec 24, 2017
1 parent 37aef6a commit bddb764
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions dingdang.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
help='Run diagnose and exit')
parser.add_argument('--debug', action='store_true', help='Show debug messages')
parser.add_argument('--info', action='store_true', help='Show info messages')
parser.add_argument('--verbose', action='store_true',
help='Directly print logs rather than writing to log file')
args = parser.parse_args()

if args.local:
Expand Down Expand Up @@ -195,14 +197,21 @@ def run(self):
''')

logging.basicConfig(
filename=os.path.join(
dingdangpath.TEMP_PATH, "dingdang.log"
),
filemode="w",
format='%(asctime)s %(filename)s[line:%(lineno)d] \
if args.verbose:
logging.basicConfig(
format='%(asctime)s %(filename)s[line:%(lineno)d] \
%(levelname)s %(message)s',
level=logging.INFO)
level=logging.INFO)
else:
logging.basicConfig(
filename=os.path.join(
dingdangpath.TEMP_PATH, "dingdang.log"
),
filemode="w",
format='%(asctime)s %(filename)s[line:%(lineno)d] \
%(levelname)s %(message)s',
level=logging.INFO)

logger = logging.getLogger()
logger.getChild("client.stt").setLevel(logging.INFO)

Expand Down

0 comments on commit bddb764

Please sign in to comment.