Package: logly
LoglyLogly is a simple logging utility for Python that provides an easy way to log messages with different levels, colors, and options. It is designed to be flexible, allowing you to customize the log messages based on your application's needs. Logly supports logging to both the console and a file, and it comes with built-in color-coded log levels for better visibility.FeaturesEasy-to-use logging for Python applications.Customizable log levels and formatting.Customizable log colors.Log to file and/or console.Log to file with automatic file rotation.Log to file with automatic file size management.Log to file with automatic file deletion.Log to file with automatic deletion and rewriting of the file when it reaches max_file_size.Getting StartedInstallationpipinstallloglyUsage# Import LoglyfromloglyimportLogly# Create a Logly instancelogly=Logly()# logly = Logly(show_time=False)  # Include timestamps in log messages default is  true, and you can set it to false will not show the time in all log messages# Start logging will store the log in text filelogly.start_logging()#make sure to include this or else the log will only display without storing itlogly.info("hello this is log")logly.info("hello this is log",color=logly.COLOR.RED)# with custom color# Log messages with different levels and colorslogly.info("Key1","Value1",color=logly.COLOR.CYAN)logly.warn("Key2","Value2",color=logly.COLOR.YELLOW)logly.error("Key3","Value3",color=logly.COLOR.RED)logly.debug("Key4","Value4",color=logly.COLOR.BLUE)logly.critical("Key5","Value5",color=logly.COLOR.CRITICAL)logly.fatal("Key6","Value6",color=logly.COLOR.CRITICAL)logly.trace("Key7","Value7",color=logly.COLOR.BLUE)logly.log("Key8","Value8",color=logly.COLOR.WHITE)# Stop logging ( messages will be displayed but not logged in file after this point)logly.stop_logging()# Log more messages after stopping logging ( messages will be displayed but not logged in file after this point)logly.info("AnotherKey1","AnotherValue1",color=logly.COLOR.CYAN)logly.warn("AnotherKey2","AnotherValue2",color=logly.COLOR.YELLOW)logly.error("AnotherKey3","AnotherValue3",color=logly.COLOR.RED)logly.info("hello this is log",color=logly.COLOR.RED,show_time=False)# with custom color and without time# Start logging againlogly.start_logging()# Set default file path and max file sizelogly.set_default_file_path("log.txt")# Set the default file path is "log.txt" if you want to set the file path where you want to save the log file.logly.set_default_max_file_size(50)# set default max file size is 50 MB# Log messages with default settings (using default file path and max file size)logly.info("DefaultKey1","DefaultValue1")logly.warn("DefaultKey2","DefaultValue2")logly.error("DefaultKey3","DefaultValue3",log_to_file=False)#DEFAULT FILE SIZE IS 100 MB in the txt file# Log messages with custom file path and max file size(optional)logly.info("CustomKey1","CustomValue1",file_path="path/c.txt",max_file_size=25)# max_file_size is in MB and create a new file when the file size reaches max_file_sizelogly.warn("CustomKey2","CustomValue2",file_path="path/c.txt",max_file_size=25,auto=True)# auto=True will automatically delete the file data when it reaches max_file_size# Access color constants directlylogly.info("Accessing color directly","DirectColorValue",color=logly.COLOR.RED)# Disable colorlogly.color_enabled=Falselogly.info("ColorDisabledKey","ColorDisabledValue",color=logly.COLOR.RED)logly.info("ColorDisabledKey1","ColorDisabledValue1",color=logly.COLOR.RED,color_enabled=True)# This will enable the color for this one log messagelogly.color_enabled=True# this will enable the color againlogly.info("ColorDisabledKey1","ColorDisabledValue1",color=logly.COLOR.RED,color_enabled=False)# this will disable the color for this one log message# Display logged messages (this will display all the messages logged so far)print("Logged Messages:")formessageinlogly.logged_messages:print(message)Explanation:Import theLoglyclass from theloglymodule.Create an instance ofLogly.Start logging using thestart_logging()method.Log messages with various levels (info, warn, error, debug, critical, fatal, trace) and colors.Stop logging using thestop_logging()method.Log additional messages after stopping logging.Start logging again.Log messages with default settings, custom file path, and max file size.Access color constants directly.Display logged messages.enable/disable timestamp supportenable/disable color for log supportfor more information check therepositorySet Default PathIf you encounter an error related to the default file path, you can use the following code snippet to set the default path:logly=Logly()logly.start_logging()# Set default file path and maximum file sizelogly.set_default_max_file_size(50)logger=os.path.join(os.path.dirname(os.path.abspath(__file__)),"log.txt")logly.set_default_file_path(logger)This will set the default file path, and you can customize it according to your requirements.Color Options:Default Color Options:LevelColor CodeINFOCYANWARNINGYELLOWERRORREDDEBUGBLUECRITICALBRIGHT REDTRACEBLUEDEFAULTWHITECustom Color Options:You can use any of the following color codes for custom coloring:NAMEColor CodeCYANCYANYELLOWYELLOWREDREDBLUEBLUEBRIGHT REDCRITICALWHITEWHITEFor example, you can usecolor=logly.COLOR.BLACKfor the black color.Tips & TricksIf you want to use logly in your project files without creating a new object in each Python file or class, you can create a file named logly.py. In this file, initialize logly and configure the defaults. Now, you can easily import and use it throughout your project:# logly.py in your root or custom path# Import LoglyfromloglyimportLoglylogly=Logly()logly.start_logging()# Set default file path and maximum file sizelogly.set_default_max_file_size(50)logger=os.path.join(os.path.dirname(os.path.abspath(__file__)),"log.txt")# This will ensure the path location to create the log.txtlogly.set_default_file_path(logger)# Start logging againlogly.start_logging()you can now use the logly byfromloglyimportlogly# make sure to import it some IDE may automatically import it on toplogly.info("msg","hello this is logly",color=logly.COLOR.RED)# with custom color of redoutput[XXXX-XX-XX XX:XX: XX] INFo: msg: hello this is loglyContributingContributions are welcome! Before contributing, please read ourContributing Guidelinesto ensure a smooth and collaborative development process.Code of ConductPlease review ourCode of Conductto understand the standards of behavior we expect from contributors and users of this project.LicenseThis project is licensed under theMIT License. SeeLICENSEfor more details.Support the Project💰 You can help me improve more by offering a little support on any platform❤️Happy Coding ❤️