The HubSpot Content Hub editor uses different log categories such as Error, Warning, and Info. Implement a logger factory that creates independent logger objects and formats messages with their configured prefixes.
The call logger("Error").log("Unable to save") must return "Error: Unable to save". A logger must also support extend(child_prefix), which creates a new logger with the child prefix appended. For example, logger("Error").extend("Validation").log("Missing title") returns "Error: Validation: Missing title".
For convenient automated testing, logger(prefix, message) may directly return the formatted result. When message is omitted, the function must return a logger object with log and extend methods.
prefix: a non-empty string.message: a string.log(message) returns a string in the format prefix + ": " + message.extend(child_prefix) returns a new logger and must not mutate the original logger.def logger(prefix, message=None):