Skip to content

Commit e7e325e

Browse files
Merge pull request #20 from GeorgeDavis-Ibexlabs/logging-github-action
Implementing logging in GitHub Action
2 parents 9346b81 + c991e5b commit e7e325e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ inputs:
3535
description: 'Set true or false to create sub-tasks'
3636
required: false
3737
default: 'false'
38+
LOG_LEVEL:
39+
description: 'Python logging level. Default: INFO'
40+
required: false
41+
default: INFO
42+
LOG_FILENAME:
43+
description: 'Python logging to file. This is the filename of the log file. Default: debug.log'
44+
required: false
45+
default: debug.log
3846
branding:
3947
icon: 'file-plus'
4048
color: 'purple'

main.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,19 @@
1111
from atlassian.adf import AtlassianDocumentFormatBuilder
1212
from utils.utils import Utils
1313

14-
logging.basicConfig()
15-
logger = logging.getLogger(__name__)
14+
# Setting up the logging level from the environment variable `LOGLEVEL`.
15+
if 'LOG_FILENAME' in environ.keys():
16+
logging.basicConfig(
17+
filename=environ['LOG_FILENAME'],
18+
filemode='a',
19+
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
20+
datefmt='%H:%M:%S'
21+
)
22+
logger = logging.getLogger(__name__)
23+
else:
24+
logging.basicConfig()
25+
logger = logging.getLogger(__name__)
26+
1627
logger.setLevel(environ['LOG_LEVEL'] if 'LOG_LEVEL' in environ.keys() else 'INFO')
1728

1829
def main():

0 commit comments

Comments
 (0)