Changeset d34008d in ammosreader


Ignore:
Timestamp:
05/18/23 12:32:55 (2 years ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
AmmosSource, guix
Children:
3c331d1
Parents:
726729c
Message:

init file rewritten for logging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ammosreader/__init__.py

    r726729c rd34008d  
    11import logging
     2import logging.config
    23import os
    34from pathlib import Path
     
    56logger = logging.getLogger(__name__)
    67
    7 logging_dir = Path(os.environ.get('AMMOS_LOG_DIR', '/var/log/'))
     8# change the default log path to /var/log/ammos/ammos.log when system configuration created this dir
     9# with the appropriate rights
     10
     11log_dir = Path(os.environ.get('AMMOS_LOG_DIR', '/tmp/'))
    812
    913log_path = log_dir / 'ammos.log'
    1014
    1115if not log_path.exists():
    12     print(log_path, "does not exist")
    13     print("Logging disabled")
    14     logging.config.fileConfig('ammos_logging.conf')
     16#   print(log_path, "does not exist")
     17    try:
     18#       print("Trying to create logfile", str(log_path))
     19        log_path.touch()
     20    except PermissionError:
     21#       print("Logging to file disabled")
     22        logging.config.fileConfig('ammos_logging.conf')
    1523else:
     24#   print("Logging to", str(log_path))
    1625    logging.basicConfig(filename=str(log_path))
Note: See TracChangeset for help on using the changeset viewer.