Skip to content

Commit

Permalink
Merge pull request #90 from felix5572/master
Browse files Browse the repository at this point in the history
if meet permission error when dumping dpdispatcher.log, will try to redirect the log to ~/dpdispatcher.log
  • Loading branch information
felix5572 committed Jul 6, 2021
2 parents 2907e7c + 78b85ab commit f7305aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dpdispatcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import logging
import os, sys

import warnings

ROOT_PATH=__path__[0]
dlog = logging.getLogger(__name__)
dlog.propagate = False
dlog.setLevel(logging.INFO)
dlogf = logging.FileHandler(os.getcwd()+os.sep+'dpdispatcher'+'.log')
try:
dlogf = logging.FileHandler(os.getcwd()+os.sep+'dpdispatcher'+'.log')
except PermissionError:
warnings.warn(f"dpdispatcher.log meet permission error. redirect the log to ~/dpdispatcher.log")
dlogf = logging.logging.FileHandler(os.path.join(os.path.expanduser('~'),'dpdispatcher.log'))

# dlogf = logging.FileHandler('./'+os.sep+SHORT_CMD+'.log')
# dlogf = logging.FileHandler(os.path.join(os.environ['HOME'], SHORT_CMD+'.log'))
# dlogf = logging.FileHandler(os.path.join(os.path.expanduser('~'), SHORT_CMD+'.log'))
Expand Down

0 comments on commit f7305aa

Please sign in to comment.