Skip to content

Commit

Permalink
make logs directory if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ju1115kr committed May 29, 2018
1 parent 1372fc5 commit cbe0ec8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import os.path
import settings
import data_manager
from policy_learner import PolicyLearner
Expand All @@ -11,13 +12,17 @@
# 로그 기록
log_dir = os.path.join(settings.BASE_DIR, 'logs/%s' % stock_code)
timestr = settings.get_time_str()
if not os.path.exists('logs'):
os.makedirs('logs')
if not os.path.exists('logs/%s' % stock_code):
os.makedirs('logs/%s' % stock_code)
file_handler = logging.FileHandler(filename=os.path.join(
log_dir, "%s_%s.log" % (stock_code, timestr)), encoding='utf-8')
stream_handler = logging.StreamHandler()
file_handler.setLevel(logging.DEBUG)
stream_handler.setLevel(logging.INFO)
logging.basicConfig(format="%(message)s",
handlers=[file_handler, stream_handler], level=logging.DEBUG)
handlers=[file_handler, stream_handler], level=logging.DEBUG)

# 주식 데이터 준비
chart_data = data_manager.load_chart_data(
Expand Down

0 comments on commit cbe0ec8

Please sign in to comment.