Skip to content

Commit

Permalink
Merge pull request #4 from NBISweden/disable-file-logging
Browse files Browse the repository at this point in the history
Add option to disable file bases logging
  • Loading branch information
costero-e authored Oct 22, 2024
2 parents afca6b3 + d712113 commit 28583ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions beacon/conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
raise_exception(err, errcode)

level=logging.NOTSET
log_file='beacon/logs/logs.log'
api_version='2.0.0'
beacon_id = 'org.ega-archive.beacon-ri-demo' # ID of the Beacon
beacon_name = 'Beacon Reference Implementation demo' # Name of the Beacon service
Expand Down
15 changes: 11 additions & 4 deletions beacon/logs/logs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import logging
import time
from beacon.conf.conf import level
from beacon.conf.conf import log_file
from typing import Optional
import os

LOG = logging.getLogger(__name__)
fh = logging.FileHandler("beacon/logs/logs.log")
fh.setLevel(level)
fmt = '%(levelname)s - %(asctime)s - %(message)s'
formatter = logging.Formatter(fmt)
fh.setFormatter(formatter)
LOG.addHandler(fh)

if log_file:
fh = logging.FileHandler(log_file)
fh.setLevel(level)
fh.setFormatter(formatter)
LOG.addHandler(fh)
else:
sh = logging.StreamHandler()
sh.setLevel(level)
sh.setFormatter(formatter)
LOG.addHandler(sh)

# LOGS per iniciar i parar el contenidor (INFO)
# LOGS per he rebut una request i retorno una response (INFO)
Expand Down

0 comments on commit 28583ed

Please sign in to comment.