diff --git a/action.yml b/action.yml index c4b544d..32ef62d 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,14 @@ inputs: description: 'Set true or false to create sub-tasks' required: false default: 'false' + LOG_LEVEL: + description: 'Python logging level. Default: INFO' + required: false + default: INFO + LOG_FILENAME: + description: 'Python logging to file. This is the filename of the log file. Default: debug.log' + required: false + default: debug.log branding: icon: 'file-plus' color: 'purple' diff --git a/main.py b/main.py index 1dbe01d..d7be8bc 100644 --- a/main.py +++ b/main.py @@ -11,8 +11,19 @@ from atlassian.adf import AtlassianDocumentFormatBuilder from utils.utils import Utils -logging.basicConfig() -logger = logging.getLogger(__name__) +# Setting up the logging level from the environment variable `LOGLEVEL`. +if 'LOG_FILENAME' in environ.keys(): + logging.basicConfig( + filename=environ['LOG_FILENAME'], + filemode='a', + format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s', + datefmt='%H:%M:%S' + ) + logger = logging.getLogger(__name__) +else: + logging.basicConfig() + logger = logging.getLogger(__name__) + logger.setLevel(environ['LOG_LEVEL'] if 'LOG_LEVEL' in environ.keys() else 'INFO') def main():