Skip to content

Commit

Permalink
adding test for log func
Browse files Browse the repository at this point in the history
  • Loading branch information
ali96343 committed Oct 2, 2023
1 parent 6c924ff commit 13311d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions py4web/server_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def check_level(level):
)


def logging_conf(level=logging.WARN, logger_name=__name__):
def logging_conf(level=logging.WARN, logger_name=__name__, test_log = False):

log_file = get_log_file()
log_to = dict()
Expand All @@ -79,11 +79,9 @@ def logging_conf(level=logging.WARN, logger_name=__name__):
time_msg = '%H:%M:%S'
#date_time_msg = '%Y-%m-%d %H:%M:%S'

msg_format = None if 'gevent' in logger_name else short_msg

try:
logging.basicConfig(
format=msg_format,
format=short_msg,
datefmt=time_msg,
level=check_level(level),
**log_to,
Expand All @@ -99,6 +97,10 @@ def logging_conf(level=logging.WARN, logger_name=__name__):
log = logging.getLogger("SA:" + logger_name)
log.propagate = True

if test_log:
for func in (log.debug, log.info, log.warn, log.error, log.critical, ) :
func('func: ' + func.__name__ )

return log


Expand Down

0 comments on commit 13311d8

Please sign in to comment.