Package: clinlog
clinlogPackage to easily log styled messages on consoleBasic usageCreate aLoggerobject and use his convenient methods to print styled messages in console. You can define a default tag for each kind of message on theLoggerinstance. There is a custom handler to use clinlog with default loggign package of python stdlib (Using custom handler expanation below).Print style methodsconfirm()error()warning()info()debug()print()The signature for all print methods are the same:message(str): Message to print.tag(str): (Optional) Prefix tag to print with the message. IfNonethe default tag for this kind of messages is used. An empty string will remove the tag for this print.bold(bool): (Optional)Trueto use bright style to print the message (kind of bold font). By defaultFalse.highlight(bool):Trueto use the color on the background and a high contrast color for the message text.invert_color(bool):Trueto invert font color when highlight flag is on, this will switch between black and white. By defaultFalse.Default print tag attributesWhen aLoggerobject is created all default tags are an empty string(no tag)confirm_tagerror_tagwarn_taginfo_tagprint_tagLog level paramYou can provide a log level parameter to control the verbosity of the logger, this parameter can be provided during construction or via setter method. By defaultLoggerclass takes max verbosity level(debug)fromclinlogimportLogger# Creating a Logger with warining log levellog=Logger(log_level='warning')# Updating log level via setterlog.log_level='debug'Code SamplefromclinlogimportLogger# Create the loggerlog=Logger()# Set default error taglog.error_tag='[ERROR]: '# Print error styled messagelog.error('Unable to access config file',bold=True)# Print warning highlighted and boldlog.warning('The execution will continue with default configuration',None,True,True)# Confirmation log with provided taglog.confirm('Execution completed','[SUCCESS]')# Debug log with provided taglog.debug('DB returned 8 entries for the user','[DEBUG] ')OutputDifferent styes sampleClinlogHandler and python logging packageTo use Clinlog with pythonlogging packageyou can create an instance ofClinlogHandlerand add it to your custom logger handlers. There are two convinent funcions to create alogging.Loggerwhith this handler setted.First here is an example of how to create a logger from logging package and add ClinlogHandler to print styled messages when logging.importloggingfromclinlog.loggingimportClinlogHandler# Create logger and handlerlogger=logging.getLogger('clinlog')cl_handler=ClinlogHandler()# Set log level and add Clinlog handler to loggerlogger.setLevel(logging.DEBUG)logger.addHandler(cl_handler)logger.critical('This is a critical error!')logger.error('This is an error')logger.warning('Some warning')logger.info('Everithing is going right for now')logger.debug('User input was 4')About the helper functions you can use them to create (create_logger()) or get the logger (get_logger()) directly.importloggingfromclinlog.loggingimportget_logger,create_logger# Creates logger with name 'clinlog'create_logger()# You can get the logger with logginglogger=logging.getLogger('clinlog')# For ease of use get_logger() creates (if needed, so you don't need to call creeate_logger before this) clinlog logger and returns itlogger=get_logger()logger.info('Logging setted up')ClinlogHandler detailsClinlogHandlerextends fromStreamHandlerfrom logging package, so you can expect same methods as this handler.The handles is by default inDEBUGlevel.The message formater is by default with format:[%(levelname)s] %(message)s(you can see an output examples below)ClinlogHandler output