Skip to content
Permalink
Browse files

Save log file at different place to prevent permission error.

    For root: /tmp/berrynet.log
    For user: $HOME/.cache/berrynet.log

Signed-off-by: Bofu Chen (bafu) <bofu@dt42.io>
  • Loading branch information...
bafu committed Apr 5, 2019
1 parent 0cec06b commit 8a4184c0850385280034812414bd7f9c6c3f81b4
Showing with 9 additions and 1 deletion.
  1. +9 −1 berrynet/__init__.py
@@ -1,4 +1,12 @@
import os

from logzero import setup_logger


logger = setup_logger(name='berrynet-logger', logfile='/tmp/berrynet.log')
# Save log file at different place to prevent permission error.
if os.geteuid() == 0: # root
LOGGING_FLLEPATH='/tmp/berrynet.log'
else:
LOGGING_FLLEPATH='{}/.cache/berrynet.log'.format(os.getenv('HOME'))

logger = setup_logger(name='berrynet-logger', logfile=LOGGING_FLLEPATH)

0 comments on commit 8a4184c

Please sign in to comment.
You can’t perform that action at this time.