You can download this code by clicking the button below.
This code is now available for download.
This function randomly selects a log level from the available levels in the Loguru library and logs a random message with two arguments using the selected log level.
Technology Stack : Loguru
Code Type : Custom Function
Code Difficulty : Intermediate
import random
from loguru import logger
def generate_random_log_level_message(arg1, arg2):
# Randomly select a log level from the available levels in loguru
log_level = random.choice(list(logger.log_level_names))
# Create a random message using the selected log level
message = f"{log_level.capitalize()} log level message with arg1: {arg1} and arg2: {arg2}"
# Log the message with the selected log level
logger.log(log_level, message)
# JSON representation of the code