Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing logging in GitHub Action #20

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
15 changes: 13 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading