Skip to content

Commit

Permalink
Rename log file and convert location to constant #247
Browse files Browse the repository at this point in the history
Reference: #305
Reference: #247

Signed-off-by: John M. Horan <[email protected]>
  • Loading branch information
johnmhoran committed Mar 7, 2024
1 parent 888d8d8 commit 9d293e8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions purldb-toolkit/src/purldb_toolkit/purlcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from packageurl import PackageURL
from packageurl.contrib import purl2url

LOG_FILE_LOCATION = os.path.join(os.path.expanduser("~"), "purlcli.log")


@click.group()
def purlcli():
Expand Down Expand Up @@ -254,7 +256,7 @@ def construct_headers(
print(warning)
continue

log_file = Path(os.path.join(os.path.expanduser("~"), "app.log"))
log_file = Path(LOG_FILE_LOCATION)
if log_file.is_file():
with open(log_file, "r") as f:
for line in f:
Expand Down Expand Up @@ -657,7 +659,7 @@ def validate_purl(purl):
print(f"validate_purl(): json.decoder.JSONDecodeError for '{purl}': {e}")

logging.basicConfig(
filename=os.path.join(os.path.expanduser("~"), "app.log"),
filename=LOG_FILE_LOCATION,
level=logging.ERROR,
format="%(levelname)s - %(message)s",
filemode="w",
Expand Down Expand Up @@ -842,7 +844,7 @@ def check_for_duplicate_input_sources(purls, file):


def clear_log_file():
log_file = Path(os.path.join(os.path.expanduser("~"), "app.log"))
log_file = Path(LOG_FILE_LOCATION)

if log_file.is_file():
os.remove(log_file)
Expand Down

0 comments on commit 9d293e8

Please sign in to comment.