Skip to content

Commit

Permalink
+ Add nxt_log.LOG_DIR constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael authored and Michael committed Jun 11, 2024
1 parent 81acccc commit 753c1c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nxt/nxt_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Internal
from .constants import USER_DIR

LOG_DIR = os.path.join(tempfile.gettempdir(), 'nxt_logs')
VERBOSE_ENV_VAR = 'NXT_VERBOSE'

"""Logging levels are as follows, with custom levels marked with *
Expand Down Expand Up @@ -248,18 +249,17 @@ def get_new_session_log_filename():
:rtype: str
"""
logger = logging.getLogger(__name__)
log_dir = os.path.join(tempfile.gettempdir(), 'nxt_logs')
try:
os.makedirs(log_dir)
os.chmod(log_dir, 0o777)
os.makedirs(LOG_DIR)
os.chmod(LOG_DIR, 0o777)
except OSError as err:
if err.errno is errno.EEXIST:
logger.debug("Not creating logs directory because it exists.")
else:
raise
log_filename_template = "nxt_session_{time}.log"
log_filename = log_filename_template.format(time=str(int(time.time())))
return os.path.join(log_dir, log_filename)
return os.path.join(LOG_DIR, log_filename)


def stop_session_log(filename):
Expand Down

0 comments on commit 753c1c5

Please sign in to comment.