octoprint.logging#
get_divider_line(c, message = None, length = 78, indent = 3)
#
Generate a divider line for logging, optionally with included message.
Examples:
>>> get_divider_line("-")
'------------------------------------------------------------------------------'
>>> get_divider_line("=", length=10)
'=========='
>>> get_divider_line("-", message="Hi", length=10)
'--- Hi ---'
>>> get_divider_line("-", message="A slightly longer text")
'--- A slightly longer text ---------------------------------------------------'
>>> get_divider_line("-", message="A slightly longer text", indent=5)
'----- A slightly longer text -------------------------------------------------'
>>> get_divider_line("-", message="Hello World!", length=10)
'--- Hello World!'
>>> get_divider_line(None)
Traceback (most recent call last):
...
AssertionError: c is not text
>>> get_divider_line("´`")
Traceback (most recent call last):
...
AssertionError: c is not a single character
>>> get_divider_line("-", message=3)
Traceback (most recent call last):
...
AssertionError: message is not text
>>> get_divider_line("-", length="hello")
Traceback (most recent call last):
...
AssertionError: length is not an int
>>> get_divider_line("-", indent="hi")
Traceback (most recent call last):
...
AssertionError: indent is not an int
Parameters:
-
c
(
str
) –character to use for the line
-
message
(
str
) –message to print in the line
-
length
(
int
) –length of the line
-
indent
(
int
) –indentation of message in line
Returns:
-
str
–formatted divider line
get_handler(name, logger = None)
#
Retrieves the handler named name
.
If optional logger
is provided, search will be
limited to that logger, otherwise the root logger will be
searched.
Parameters:
-
name
(
str
) –the name of the handler to look for
-
logger
(
logging.loggers.Logger
) –(optional) the logger to search in, root logger if not provided
Returns: