def get_log_category(line_text):
    """Return category name of content the line text holds."""
    ### remove specific substrings if they exist, otherwise,
    ### consider the text as normal text by returning 'normal'

    ## substring at the beginning of the string

    if line_text.startswith(HEADER_START):
        line_text = line_text[len(HEADER_START) :]

    else:
        return "normal"

    ## substring at the end of the string

    if line_text.endswith(HEADER_END):
        line_text = line_text[: -len(HEADER_END)]

    else:
        return "normal"

    ### try separating the text into a head and tail
    ### portions using a known excerpt of text used in
    ### headers
    level_name, sep, time_str = line_text.partition(" message logged at ")

    ### the line text can't be a header in the following
    ### cases, so return 'normal'...

    if (
        ## if there is not separator, it means the separation
        ## didn't succeed, so the text can't be a user log
        ## header...
        not sep
        ## or if the level name captured isn't allowed
        or level_name not in LOG_LEVELS
        ## or yet if the time string captured doesn't validate
        or not validate_time_str(time_str)
    ):
        return "normal"

    ### otherwise we have a header, so we return its
    ### respective category name according to its level
    ### name
    else:
        return CATEGORY_NAME_MAP[level_name]
Return category name of content the line text holds.
nodezator/syntaxman/syntaxes/userlog.py