There doesn't seem to be a way to change the log file name. This is possible by setting the log_session_filename
**global-logger.py**
# pylint: disable=too-many-locals,too-many-arguments,too-many-statements
def __init__(self, name, level=None, global_level=True, logs_dir=None, # noqa: C901
max_log_files=None, file_message_format=None, screen_message_format=None, date_format_full=None,
date_format=None, direct=True, log_session_filename=None):
if direct:
raise ValueError("You should create Global Logger via Log.get_logger() method.")
level = level or Log.GLOBAL_LOG_LEVEL
# pylint: disable=invalid-envvar-default
verbose = os.getenv('LOG_VERBOSE', False)
if global_level and verbose:
level = Log.Levels.DEBUG
self.name = name
Log.log_session_filename = log_session_filename
----------------------------------------------------
if Log.log_session_filename is None:
# pylint: disable=import-outside-toplevel
from pendulum.tz.zoneinfo.exceptions import InvalidZoneinfoFile
try:
now = pendulum.now()
except InvalidZoneinfoFile:
now = pendulum.now(pendulum.UTC) # travis-ci precaution
Log.log_session_filename = "%s.log" % now.strftime('%Y-%m-%d_%H-%M-%S')
else:
Log.log_session_filename = str(log_session_filename + ".log")
self._clean_logs_folder()
-------------------------------------------------------------------------------------------------------------------
@classmethod
def get_logger(cls, name=None, level=None, global_level=True, logs_dir=None, max_log_files=None, file_message_format=None,
screen_message_format=None, date_format_full=None, date_format=None, log_session_filename=None):
"""
Main instantiating method for the class. Use it to instantiate global logger.
:param name: a unique logger name that is re-/used if already exists, defaults to the function path.
:type name: str or unicode
:param level: Logging level for the current instance.
:type level: int
:param global_level: Treat this level as a global (True) or as an individual (False)
Individual loggers do not gain global logging level changes.
:type global_level: bool
:param logs_dir: Path where the .log files would be created, if provided.
:type logs_dir: Path or str or None
:param max_log_files: Maximum .log files to store.
:type max_log_files: int
:param screen_message_format: Screen Logging message format.
:type screen_message_format: str
:param file_message_format: File Logging message format.
:type file_message_format: str
:param date_format_full: Logging full date format.
:type date_format_full: str
:param date_format: Logging on-screen date format.
:type date_format: str
:param log_session_filename: a unique log file name
:type log_session_filename: str
:return: :class:`Log` instance to work with.
:rtype: :class:`Log`
"""
name = name or get_prev_function_name()
output = Log.loggers.get(name) or cls(name, level=level, global_level=global_level, logs_dir=logs_dir,
max_log_files=max_log_files, file_message_format=file_message_format,
screen_message_format=screen_message_format, date_format_full=date_format_full,
date_format=date_format, direct=False, log_session_filename=log_session_filename)
Log.loggers[name] = output
Log._add_autoadded_handlers()
return output