Package: py-easy-logger
easy-loggerSimple Easy baseline Logger. Creates a color stream logger or a basic rotating logger that can be used and called on throughout a project.UsageConfiguration Values:name:Name of file can use built in__name__or specifiy a name to call the logger instance.logName:filename for log.logDir:Directory location to store log.Can use built in utilitiy to find the default log location for the system you are on.level:Log Level. Can be one of the following Strings.NOTSET = 0DEBUG = 10INFO = 20WARN = 30WARNING = 30ERROR = 40CRITICAL = 50FATAL = 50setFile:Bool Value to set the logger to write out to file.stream:Bool Value to allow conosole output of log.maxBytes:Maximum Byte size before rotating log file.backupCount:Amount of backups to keep.setLog:Enables or creates the logging instance otherwise will not log anything.importeasy_loggerfromeasy_logger.utilsimportset_logdirlogger=easy_logger.RotatingLog(__name__,logName="sample.log",logDir=set_logdir("default"),level="DEBUG",stream=True,setLog=True,setFile=True,maxBytes=10000,backupCount=10)log=logger.getLogger(__name__)log.info(f"Writting out file to:{set_logdir('default')}")log.info("This is an informational log message.")log.debug("This is a debug log message.")log.warning("This is a warning log message.")log.critical("This is a critical log message.")What this will look like in the console:If written to file:>>>cat~/Library/Logs/sample.log[2023-07-1912:25:01,648]level=INFOname=__main__fn=<ipython-input-1-e1c5bba1549c>ln=14func=<module>:Writtingoutfileto:~/Library/Logs[2023-07-1912:25:01,650]level=INFOname=__main__fn=<ipython-input-1-e1c5bba1549c>ln=15func=<module>:Thisisaninformationallogmessage.[2023-07-1912:25:01,652]level=DEBUGname=__main__fn=<ipython-input-1-e1c5bba1549c>ln=16func=<module>:Thisisadebuglogmessage.[2023-07-1912:25:01,658]level=WARNINGname=__main__fn=<ipython-input-1-e1c5bba1549c>ln=17func=<module>:Thisisawarninglogmessage.[2023-07-1912:25:01,667]level=CRITICALname=__main__fn=<ipython-input-1-e1c5bba1549c>ln=18func=<module>:Thisisacriticallogmessage.If thenamevalue is passed as a string instead of using the python file name the name will show up in the logs such as:log=logger.getLogger("easy_logger")Sample Log File Output Format[2023-07-1912:34:53,266]level=INFOname=easy_loggerfn=<ipython-input-2-297430e75a74>ln=14func=<module>:Writtingoutfileto:~/Library/Logs[2023-07-1912:34:53,268]level=INFOname=easy_loggerfn=<ipython-input-2-297430e75a74>ln=15func=<module>:Thisisaninformationallogmessage.[2023-07-1912:34:53,268]level=DEBUGname=easy_loggerfn=<ipython-input-2-297430e75a74>ln=16func=<module>:Thisisadebuglogmessage.[2023-07-1912:34:53,269]level=WARNINGname=easy_loggerfn=<ipython-input-2-297430e75a74>ln=17func=<module>:Thisisawarninglogmessage.[2023-07-1912:34:53,269]level=CRITICALname=easy_loggerfn=<ipython-input-2-297430e75a74>ln=18func=<module>:Thisisacriticallogmessage.NOTE:It is usually best practice when passing a logger around a large project to pick up the name of the file and the function for easier troubleshooting depending on what method you use.Extended FunctionsApplication Log Directory:You can set up a subdirectory for your application on a system using the system's default location by leveraging and extension function in the logDir value.importeasy_loggerfromeasy_logger.utilsimportset_logdirlogger=easy_logger.RotatingLog(__name__,logName="sample.log",logDir=set_logdir("extend",extend="ApplicationName"),level="DEBUG",stream=True,setLog=True,setFile=True,maxBytes=10000,backupCount=10)log=logger.getLogger(__name__)log.info(f"log directory set to{logger.settings.logDir}")log.info("This is an informational log message.")log.debug("This is a debug log message.")log.warning("This is a warning log message.")log.critical("This is a critical log message.")Sample Application Log Directory Output>>>cat~/Library/Logs/ApplicationName/sample.log[2023-07-2813:03:48,438]level=INFOname=__main__fn=<ipython-input-3-edd6755574f8>ln=1func=<module>:logdirectorysetto~/Library/Logs/ApplicationName[2023-07-2813:03:48,443]level=INFOname=__main__fn=<ipython-input-3-edd6755574f8>ln=2func=<module>:Thisisaninformationallogmessage.[2023-07-2813:03:48,446]level=DEBUGname=__main__fn=<ipython-input-3-edd6755574f8>ln=3func=<module>:Thisisadebuglogmessage.[2023-07-2813:03:48,450]level=WARNINGname=__main__fn=<ipython-input-3-edd6755574f8>ln=4func=<module>:Thisisawarninglogmessage.[2023-07-2813:03:48,452]level=CRITICALname=__main__fn=<ipython-input-3-edd6755574f8>ln=5func=<module>:Thisisacriticallogmessage.Versionsv0.0.6Added color samples as defaults.Created a Color Console only.Updated reformat error to remove[,]characters as it causes issues reading on some systems; replaced withlist().Added ability to change Log Format for streaming.v0.0.5Added a retry decorator.Added Error handler with ability to customize the error return value or ability to log out the error.BUGFIXissue with reformat Exception when added to a JSON object can become problematic so filtering out ugly formating from raised Exception.v0.0.4Added utility to find OS Log directory.Added Splunk JSON data formatter.v0.0.3Added Splunk basic string log out format.Added Splunk HEC JSON format for messaging.Future EnhancementsUse a standard or basic logger.Allow conversion of int/str types for log level.