Skip to content

Commit

Permalink
adds default log level support
Browse files Browse the repository at this point in the history
  • Loading branch information
stgmsa committed Jan 3, 2025
1 parent 7d5777a commit 4ff8d7f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bin/pyntlm_auth/log.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
import logging
import os


def init_logging():
available_logging_levels = {'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'}
logging_level = os.getenv('LOG_LEVEL')

if not logging_level:
logging_level = 'DEBUG'

if logging_level not in available_logging_levels:
logging_level = 'DEBUG'

default_logging_level = logging.DEBUG

if logging_level == 'INFO':
default_logging_level = logging.INFO
elif logging_level == 'WARNING':
default_logging_level = logging.WARNING
elif logging_level == 'ERROR':
default_logging_level = logging.ERROR
elif logging_level == 'CRITICAL':
default_logging_level = logging.CRITICAL

logger = logging.getLogger("ntlm-auth")
logger.setLevel(default_logging_level)

Expand Down
10 changes: 10 additions & 0 deletions conf/log.conf.d/ntlm-auth-api.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) Inverse inc.
## Update Log level for ntlm-auth-api
##

# Available log levels are:
# DEBUG, INFO, WARNING, ERROR, CRITICAL
# Default log level is DEBUG

LOG_LEVEL=DEBUG

1 change: 1 addition & 0 deletions conf/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ExecStop=/bin/bash -c "docker stop ntlm-auth-api-%i; echo Stopped"
Restart=on-failure
Slice=packetfence.slice
PIDFile=/usr/local/pf/var/run/ntlm-auth-api-%i-systemd-notify.pid
EnvironmentFile=-/usr/local/pf/conf/log.conf.d/ntlm-auth-api.conf

[Install]
WantedBy=packetfence.target
Expand Down

0 comments on commit 4ff8d7f

Please sign in to comment.