Package: signale-logging
Signale.pyElegant Console Logger For Python Command-Line AppsInstallationSignale.pycan be installed using pip.[sudo]pipinstallsignalepyUsagePackage consists of a classSignale, it is the main constructor class. The object created has all the logger functions in it.Using LoggersEach logger function takes four arguments:-textprefix( Optional )suffix( Optional )level( Optional )They all are available in the logger object. To create one do this:-fromsignalepyimportSignalelogger=Signale()Now you can use the default loggers using this object like:-...logger.success("Started Successfully",prefix="Debugger")logger.warning("`a` function is deprecated",suffix="main.py")logger.complete("Run Complete")...This will produce the following result:-View All Available Loggerssimplesuccesserrorexception(same aserror, but also prints a formatted stack backtrace)warning(=warn)startstopwatchimportantpendingcompletedebugxdebugpauseinfolikecenterboldunderlinereversedcoloured(=colored)Scoped LoggersTo create scoped loggers, define thescopefield in theoptionsargument of constructor like:-fromsignalepyimportSignalelogger=Signale({"scope":"global scope"})logger.success("Scoped Logger Works!")This will produce the following result:-You also create multiple scopes by setting thescopefield to a list of strings like:-fromsignalepyimportSignalelogger=Signale({"scope":["global scope","inner scope"]})logger.success("Scoped Logger Works!")This will produce the following result:-You can also create scoped a logger which is just clone of other by using by using thescopedfunction like this:-fromsignalepyimportSignalelogger=Signale({"scope":"global scope"})logger2=logger.scoped("inner")logger2.like("I love Signale.py",prefix="Shardul Nalegave",suffix="Creator")This will produce the following result:-Note:-All the configuration will be copied to the new logger just the scope will be extended.Filtering With LevelsAll logging output can be filtered based on levels and thresholds. All logging
methods have an optionallevelargument, pre-filled with one ofXDEBUG,DEBUG,INFO,WARNING,ERROR, orCRITICAL. For most, the default
should be obvious, the others useINFO.By default, all levels are visible. The threshold of visibility can be raised
with theset_threshold(scope, level)module function globally, wherescopeis the name of a scope, orNone(akaGLOBAL_SCOPE). The levels can also
be specified as an uppercase string.Any of the named scopes associated with a logger with a defined threshold will
have to be surpassed by thelevel. If there is no explicit threshold for any
named scopes, theGLOBAL_SCOPEwill be used.This means that the threshold of any named scopes can be raised or lowered
independent of the global scope's threshold. However, for named scopes with a
specified threshold, the lowest threshold of them will be used; i.e., it is not
possible to raise the threshold for a sub-scope.Aligning labelsThe module supports a functionset_align(left, right), which allows for the
alignment of scopes and labels. Default are strings "  " and ":  " forleftandright, which will be put before/after the scope and labels. These strings
can be set to different strings. Alternatively, they can be changed to numbers,
to specify the width of the respective fields. Care should be taken that the
numbers are chosen large enough to make things aligned.Custom LoggersCustom loggers can be created by passing a array of custom logger configuration to the fieldcustomin the options passed to the constructor. Even clone loggers inherit the parent's custom loggers. For example:-fromsignalepyimportSignalelogger=Signale({"scope":"global scope","custom":[{"badge":"!","label":"Attention","color":"red","name":"attention"}]})logger2=logger.scoped("inner")logger.attention("It Works!")logger2.attention("With Logger2")This will produce the following result:-Underlined LabelsYou can set labels to be underlined by setting theunderlinedfield toTruein the options passed to the constructor. For example:-fromsignalepyimportSignales=Signale({"underlined":True})s.center("Testing Logger")s.simple("ABC",prefix="Debugger",suffix="xyz")s.info("Starting",prefix="Debugger")s.success("Started Successfully",prefix="Debugger",suffix="xyz")s.watch("Watching All Files",prefix="Debugger")s.error("Something Went Wrong",prefix="Debugger")s.warning("Deprecation Warning",prefix="Debugger")s.pending("Postponed",prefix="Debugger")s.debug("Found A Bug on L55",prefix="Debugger")s.start("Started New Process",prefix="Debugger")s.pause("Process Paused",prefix="Debugger")s.complete("Task Completed",prefix="Debugger")s.important("New Update Available. Please Update!",prefix="Debugger")s.like("I Love Signale",prefix="Debugger")s.stop("Stopping",prefix="Debugger")This will produce the following result:-OptionsOptions taken by constructorscopeType:strorlistSignale Logger ScopeunderlinedType:boolLabels Should Be Underlined Or NotansiType:boolorNoneWhether To Use ANSI Sequences.Nonewill autodetect whetherstdoutis a TTY and only use color there.customType:listList of custom logger configuration.Configuration Type:dictCustom Logger Configuration DictionaryKeysnameType:strName of the loggerlabelType:strLabel displayed beside the icon ( colored text )badgeType:strIconcolorType:strColor of the icon and label. Should be from:-reddarkbluepinkgreengreypurpleyellowcyanreset(color reset code)APIlogger =Signale(<options>)SignaleType:classSignale class imported fromsignalepymoduleoptionsType:dictOptions Dictionary for logger.Returns: Signale Logger ObjectLogger object which can be used for logginglogger.<logger>(message="", prefix="", suffix="")loggerType:functionCan be any default loggermessageType:strMessage to be displayedprefixType:strRequired: FalsePrefix textsuffixType:strRequired: FalseSuffix textReturns:Nonelogger2 =logger.scoped(<new scope>)loggerType: Signale Logger ObjectParent Loggernew scopeType:strNew Scope NameReturns: Signale Logger ObjectClone Logger object with extended scope