MCPcopy Index your code
hub / github.com/Breakthrough/PySceneDetect / init_logger

Function init_logger

scenedetect/platform.py:175–209  ·  view source on GitHub ↗

Initializes logging for PySceneDetect. The logger instance used is named 'pyscenedetect'. By default the logger has no handlers to suppress output. All existing log handlers are replaced every time this function is invoked. Arguments: log_level: Verbosity of log messages. Should

(
    log_level: int = logging.INFO, show_stdout: bool = False, log_file: str | None = None
)

Source from the content-addressed store, hash-verified

173
174
175def init_logger(
176 log_level: int = logging.INFO, show_stdout: bool = False, log_file: str | None = None
177):
178 """Initializes logging for PySceneDetect. The logger instance used is named 'pyscenedetect'.
179 By default the logger has no handlers to suppress output. All existing log handlers are replaced
180 every time this function is invoked.
181
182 Arguments:
183 log_level: Verbosity of log messages. Should be one of [logging.INFO, logging.DEBUG,
184 logging.WARNING, logging.ERROR, logging.CRITICAL].
185 show_stdout: If True, add handler to show log messages on stdout (default: False).
186 log_file: If set, add handler to dump debug log messages to given file path.
187 """
188 # Format of log messages depends on verbosity.
189 INFO_TEMPLATE = "[PySceneDetect] %(message)s"
190 DEBUG_TEMPLATE = "%(levelname)s: %(module)s.%(funcName)s(): %(message)s"
191 # Get the named logger and remove any existing handlers.
192 logger_instance = logging.getLogger("pyscenedetect")
193 logger_instance.handlers = []
194 logger_instance.setLevel(log_level)
195 # Add stdout handler if required.
196 if show_stdout:
197 handler = logging.StreamHandler(stream=sys.stdout)
198 handler.setLevel(log_level)
199 handler.setFormatter(
200 logging.Formatter(fmt=DEBUG_TEMPLATE if log_level == logging.DEBUG else INFO_TEMPLATE)
201 )
202 logger_instance.addHandler(handler)
203 # Add debug log handler if required.
204 if log_file:
205 log_file = get_and_create_path(log_file)
206 handler = logging.FileHandler(log_file)
207 handler.setLevel(logging.DEBUG)
208 handler.setFormatter(logging.Formatter(fmt=DEBUG_TEMPLATE))
209 logger_instance.addHandler(handler)
210
211
212##

Callers 2

__init__.pyFile · 0.90
_initialize_loggingMethod · 0.90

Calls 1

get_and_create_pathFunction · 0.85

Tested by

no test coverage detected