diff --git a/.gitignore b/.gitignore index 15d9ce5..5c06118 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,9 @@ .venv .idea *.iml -*.ipr \ No newline at end of file +*.ipr +venv +bin + +log.txt +.log diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b553910..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Zeppelin ignored files -/ZeppelinRemoteNotebooks/ -# GitHub Copilot persisted chat sessions -/copilot/chatSessions diff --git a/.idea/git_toolbox_prj.xml b/.idea/git_toolbox_prj.xml deleted file mode 100644 index 02b915b..0000000 --- a/.idea/git_toolbox_prj.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index cac6d52..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/logg.iml b/.idea/logg.iml deleted file mode 100644 index 8c62a0c..0000000 --- a/.idea/logg.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 97e9958..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 63b879a..56cd933 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,12 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Stability](https://img.shields.io/badge/Stability-Stable-green)](https://github.com/muhammad-fiaz/logly) [![Follow me on GitHub](https://img.shields.io/github/followers/muhammad-fiaz?label=Follow&style=social)](https://github.com/muhammad-fiaz) - - discord invite - + +[![Join My Discord](https://img.shields.io/badge/Join%20My%20Discord-7289DA?style=for-the-badge&logo=discord)](https://discord.gg/cFnFdeFw) +[![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-muhammad_fiaz-ff69b4?style=for-the-badge&logo=github)](https://github.com/sponsors/muhammad-fiaz) + +[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W) + Tired of writing custom logging code for your Python applications? @@ -40,7 +40,6 @@ if you like this project, make sure to star 🌟 it in the [repository](https:// 3. [Features](#features) 4. [Usage](#usage) - [Getting Started](#getting-started) - - [Explanation](#explanation) 5. [Set Default Path](#set-default-path) 6. [Color Options](#color-options) - [Default Color Options](#default-color-options) @@ -50,6 +49,8 @@ if you like this project, make sure to star 🌟 it in the [repository](https:// 9. [Code of Conduct](#code-of-conduct) 10. [License](#license) 11. [Support the Project](#support-the-project) + - [Become a Sponsor on GitHub](#become-a-sponsor-on-github) + - [Support via Ko-fi](#support-via-ko-fi) 12. [Happy Coding](#happy-coding) @@ -71,75 +72,83 @@ if you like this project, make sure to star 🌟 it in the [repository](https:// ## Installation +To install the stable version of `logly`, use: ```bash pip install logly ``` -## Usage +If you want to install the latest development version directly from GitHub, you can run: +```bash +pip install git+https://github.com/muhammad-fiaz/logly.git +``` +## Usage +Once installed, you can use `logly` in your Python project for logging. Here is a basic example of how to set it up and use it: ```python # Import Logly from logly import Logly # Create a Logly instance logly = 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 file -logly.start_logging() #make sure to include this or else the log will only display without storing it in file +# Start logging to store the logs in a text file +logly.start_logging() # Make sure to include this or else the logs will only display without being saved to a file -logly.info("hello this is log") -logly.info("hello this is log", color=logly.COLOR.RED) # with custom color +logly.info("Application started successfully.") +logly.info("User logged in", color=logly.COLOR.GREEN) # with custom color # Log messages with different levels and colors -logly.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.info("Database connection established", "Connection details: host=db.local, port=5432", color=logly.COLOR.CYAN) +logly.warn("API rate limit exceeded", "API request count exceeded 1000", color=logly.COLOR.YELLOW) +logly.error("Database connection failed", "Unable to reach database at db.local", color=logly.COLOR.RED) +logly.debug("User request details", "User requested resource /api/data", color=logly.COLOR.BLUE) +logly.critical("Critical system failure", "Disk space usage exceeded 95%", color=logly.COLOR.CRITICAL) +logly.fatal("Application crashed", "Unhandled exception in user module", color=logly.COLOR.CRITICAL) +logly.trace("Debug trace", "Trace info: function call stack", color=logly.COLOR.BLUE) +logly.log("System status", "All systems operational", color=logly.COLOR.WHITE) + +# Stop logging (messages will be displayed but not logged to 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) +# Log more messages after stopping logging (messages will be displayed but not logged in file) +logly.info("User session ended", "User logged out", color=logly.COLOR.CYAN) +logly.warn("Low disk space", "Disk space is below 10%", color=logly.COLOR.YELLOW) +logly.error("File not found", "Unable to find /config/settings.json", color=logly.COLOR.RED) +# Example of retrieving and printing a logged message +get_message = logly.info("New feature deployed", "Version 2.0 live now", color=logly.COLOR.RED) +print(get_message) # You can use the returned message in your application (optional) -logly.info("hello this is log", color=logly.COLOR.RED,show_time=False) # with custom color and without time +# Log message with custom color and no timestamp +logly.info("Custom log without time", "This log message does not include a timestamp", color=logly.COLOR.RED, show_time=False) # Start logging again -logly.start_logging() +logly.start_logging() # Set the default file path and max file size -logly.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 +logly.set_default_file_path("application_logs.txt") # Set the default file path +logly.set_default_max_file_size(50) # Set default max file size to 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) +logly.info("Default logging example", "Logging to default file path and size") +logly.warn("File logging size test", "Max file size set to 50 MB", log_to_file=False) -#The 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_size -logly.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 +# Log messages with custom file path and max file size (optional) +logly.info("Logging with custom file path", "This will create a new log file", file_path="logs/custom_log.txt", max_file_size=25) +logly.warn("Auto file size management", "Log file will be auto-deleted when size exceeds limit", file_path="logs/auto_delete_log.txt", max_file_size=25, auto=True) -# Access color constants directly -logly.info("Accessing color directly", "DirectColorValue", color=logly.COLOR.RED) +# Access color constants directly for logging +logly.info("Using color constants directly", "This message is in red", color=logly.COLOR.RED) -# Disable color +# Disable color for logging logly.color_enabled = False -logly.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 message -logly.color_enabled = True -# this will enable the color again -logly.info("ColorDisabledKey1", "ColorDisabledValue1", color=logly.COLOR.RED,color_enabled=False) # this will disable the color for this one log message +logly.info("Logging without color", "This log message is displayed without color", color=logly.COLOR.RED) + +# Enable color for specific log message +logly.info("Enable color for this message", "This message will have color", color=logly.COLOR.RED, color_enabled=True) +# Disable color for specific log message +logly.info("Disable color for this message", "This message will be displayed without color", color=logly.COLOR.RED, color_enabled=False) # Display logged messages (this will display all the messages logged so far) print("Logged Messages:") @@ -147,20 +156,6 @@ for message in logly.logged_messages: print(message) ``` -## Explanation: - -1. Import the `Logly` class from the `logly` module. -2. Create an instance of `Logly`. -3. Start logging using the `start_logging()` method. -4. Log messages with various levels (info, warn, error, debug, critical, fatal, trace) and colors. -5. Stop logging using the `stop_logging()` method. -6. Log additional messages after stopping logging. -7. Start logging again. -8. Log messages with default settings, custom file path, and max file size. -9. Access color constants directly. -10. Display logged messages. -11. enable/disable timestamp support -12. enable/disable color for log support for more information, check the [repository](https://github.com/muhammad-fiaz/logly) @@ -267,7 +262,7 @@ logly.info("msg","hello this is logly", color=logly.COLOR.RED) # with custom col ``` ### output ``` -[XXXX-XX-XX XX:XX: XX] INFo: msg: hello this is logly +[XXXX-XX-XX XX:XX: XX] INFO: msg: hello this is logly ``` @@ -281,17 +276,29 @@ Please review our [Code of Conduct](CODE_OF_CONDUCT.md) to understand the standa ## License This project is licensed under the [MIT License](). See [LICENSE](LICENSE) for more details. + ## Support the Project -
+
-_Support the Project by Becoming a Sponsor on GitHub_ +Your support helps improve Logly and enables us to continue adding more features and improvements. If you'd like to contribute and support the development of this project, consider becoming a sponsor on GitHub or Ko-fi. + + + + +### Become a Sponsor on GitHub +Support Logly directly on GitHub to help sustain ongoing development. [![Sponsor muhammad-fiaz](https://img.shields.io/badge/Sponsor-%231EAEDB.svg?&style=for-the-badge&logo=GitHub-Sponsors&logoColor=white)](https://github.com/sponsors/muhammad-fiaz) +### Support via Ko-fi +If you prefer, you can also support the project via Ko-fi. -
+[![Support on Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F6MME1W) +Thank you for supporting the project! 🙏 + + ## Happy Coding diff --git a/logly/logly.py b/logly/logly.py index 8b7f3b4..8c31ac9 100644 --- a/logly/logly.py +++ b/logly/logly.py @@ -1,5 +1,5 @@ # logly.py -# # Path: logly/logly.py +# Path: logly/logly.py """ Logly: A ready to go logging utility. @@ -16,6 +16,7 @@ """ import os +import logging from colorama import Fore, Style, init from datetime import datetime import re @@ -24,32 +25,23 @@ init(autoreset=True) - class Logly: """ - Logly: A simple logging utility. + Logly: A ready-to-go logging utility. + + This class provides methods to log messages with different levels of severity, + including INFO, WARNING, ERROR, DEBUG, CRITICAL, and custom LOG levels. It supports + colored output and logging to files with automatic file rollover. Attributes: - - COLOR_MAP (dict): Mapping of log levels to color codes. - - COLOR (class): Color constants for log messages. - - DEFAULT_MAX_FILE_SIZE_MB (int): Default maximum file size in megabytes. - - Methods: - - __init__: Initialize Logly instance. - - start_logging: Enable logging. - - stop_logging: Disable logging. - - disable_file_logging: Disable logging to a file. - - enable_file_logging: Enable logging to a file. - - set_default_file_path: Set default file path. - - set_default_max_file_size: Set default maximum file size. - - get_current_datetime: Get current date and time as a formatted string. - - remove_color_codes: Remove ANSI color codes from text. - - _log: Internal method to log a message. - - log_function: Log a message with exception handling. - - info, warn, error, debug, critical, fatal, trace: Log messages with different levels. - - log: Log a message with the INFO level. + ----------- + COLOR_MAP : dict + A mapping of log levels to their respective colors. + DEFAULT_MAX_FILE_SIZE_MB : int + The default maximum file size for log files in megabytes. + DEFAULT_COLOR_ENABLED : bool + The default setting for enabling colored output. """ - COLOR_MAP = { "DEBUG": Fore.BLUE, "INFO": Fore.CYAN, @@ -61,6 +53,9 @@ class Logly: # Define color constants class COLOR: + """ + A class to define color constants for log messages. + """ BLUE = Fore.BLUE CYAN = Fore.CYAN YELLOW = Fore.YELLOW @@ -74,16 +69,43 @@ class COLOR: def __init__(self, show_time=True, color_enabled=None): """ - Initialize a Logly instance. - - Attributes: - - logging_enabled (bool): Flag indicating whether logging is enabled. - - log_to_file_enabled (bool): Flag indicating whether logging to a file is enabled. - - logged_messages (list): List to store logged messages. - - default_file_path (str): Default file path for logging. - - default_max_file_size (int): Default maximum file size for logging. - - show_time (bool): Flag indicating whether to include timestamps in log messages. - """ + Initialize the Logly instance. + + This constructor sets up the initial state of the Logly logger, including + logging preferences, file paths, and color settings. + + Parameters: + ----------- + show_time : bool, optional + Whether to include timestamps in log messages (default is True). + color_enabled : bool, optional + Whether to enable colored output. If None, uses the default color setting. + + Attributes: + ----------- + logging_enabled : bool + Flag to enable/disable logging. + log_to_file_enabled : bool + Flag to enable/disable logging to a file. + logged_messages : list + List to store logged messages. + default_file_path : str or None + Default path for log files. + default_max_file_size : int + Default maximum file size for log files. + show_time : bool + Whether to show timestamps in log messages. + color_enabled : bool + Whether color output is enabled. + default_color_enabled : bool + Default setting for color output. + logger : logging.Logger + Python's built-in logger instance. + + Returns: + -------- + None + """ self.logging_enabled = False self.log_to_file_enabled = True self.logged_messages = [] @@ -93,6 +115,16 @@ def __init__(self, show_time=True, color_enabled=None): self.color_enabled = color_enabled if color_enabled is not None else self.DEFAULT_COLOR_ENABLED # Use the provided value or default self.default_color_enabled = self.color_enabled # Store the default color state + # Disable default logging setup for this logger + self.logger = logging.getLogger(__name__) + self.logger.setLevel(logging.DEBUG) + # Ensure there are no default handlers that duplicate the log messages + if not self.logger.hasHandlers(): + handler = logging.StreamHandler() + formatter = logging.Formatter('%(message)s') # Format only the message, no additional time or level + handler.setFormatter(formatter) + self.logger.addHandler(handler) + def start_logging(self): """ Enable logging. @@ -160,91 +192,97 @@ def remove_color_codes(self, text): def _log(self, level, key, value, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Internal method to log a message. + Internal method to handle logging operations. - Parameters: - - level (str): Log level (e.g., "INFO", "ERROR"). - - key (str): The key associated with the log message. - - value (str): The value of the log message. - - color (str): ANSI color code for the log message. - - log_to_file (bool): Whether to log to a file. - - file_path (str): File path for logging. - - file_name (str): File name for logging. - - max_file_size (int): Maximum file size for logging. - - auto (bool): Whether to auto-delete log file data when the size limit is reached. - - show_time (bool): Whether to include timestamps in the log message. - - color_enabled (bool): Whether to enable color in the log message. - - """ - color_enabled = color_enabled if color_enabled is not None else self.color_enabled # Use the provided value or default + This method processes the log message, applies formatting, and handles both console and file logging. + + Args: + level (str): The log level (e.g., "INFO", "WARNING", "ERROR", etc.). + key (str): The key for the log message. If None, it's treated as an empty string. + value (str): The main content of the log message. + color (str, optional): The color to use for the log message. If None, a default color is used based on the log level. + log_to_file (bool, optional): Whether to log the message to a file. Defaults to True. + file_path (str, optional): The path where the log file will be stored. If None, uses the default path. + file_name (str, optional): The name of the log file. If provided, it overrides the file_path. + max_file_size (int, optional): The maximum size of the log file in MB before rolling over. + auto (bool, optional): If True, automatically handles file rollover when max_file_size is reached. Defaults to True. + show_time (bool, optional): Whether to include a timestamp in the log message. If None, uses the instance's default. + color_enabled (bool, optional): Whether to enable colored output. If None, uses the instance's default. + + Returns: + str: The formatted log message with color codes removed. + + Raises: + FilePathNotFoundException: If the specified file path does not exist. + FileAccessError: If there's an error accessing the log file. + FileCreationError: If there's an error creating or writing to the log file. + """ + color_enabled = color_enabled if color_enabled is not None else self.color_enabled if show_time is None: show_time = self.show_time timestamp = "" if not show_time else self.get_current_datetime() - + if key is None: + key = "" # Set key to empty string if it is None + else: + key = f"{key}:" if color_enabled and show_time: - # Apply color if both color and time are enabled color = color or self.COLOR_MAP.get(level, self.COLOR.BLUE) - log_message = f"[{timestamp}] {level}: {color}{key}: {value}{Style.RESET_ALL}" + log_message = f"{color}[{timestamp}] - {level}: {key} {value}{Style.RESET_ALL}" elif color_enabled and not show_time: - # Apply color if only color is enabled color = color or self.COLOR_MAP.get(level, self.COLOR.BLUE) - log_message = f" {level}: {color}{key}: {value}{Style.RESET_ALL}" + log_message = f"{color} {level}: {key} {value}{Style.RESET_ALL}" elif not color_enabled and show_time: - # Do not apply color, but include timestamp if only time is enabled - log_message = f"[{timestamp}] {level}: {key}: {value}" + log_message = f"[{timestamp}] - {level}: {key} {value}" else: - # Do not apply color or timestamp if neither is enabled - log_message = f"{level}: {key}: {value}" - - # Log to console - print(log_message) + log_message = f"{level}: {key} {value}" + + # Log to console using logging library + if level == "INFO": + self.logger.info(log_message) + elif level == "WARNING": + self.logger.warning(log_message) + elif level == "ERROR": + self.logger.error(log_message) + elif level == "DEBUG": + self.logger.debug(log_message) + elif level == "CRITICAL": + self.logger.critical(log_message) + else: + self.logger.log(logging.NOTSET, log_message) if self.log_to_file_enabled and log_to_file: try: - # Remove color codes before storing in the log file log_message_without_color = self.remove_color_codes(log_message) + # Encode emojis properly + log_message_without_color = log_message_without_color.encode('utf-8', 'replace').decode() - # Determine the file path and name if file_path is None: - file_path = self.default_file_path or os.path.join(os.getcwd(), - "log.txt") # Default file path and name in the project root + file_path = self.default_file_path or os.path.join(os.getcwd(), "log.txt") elif file_name: - file_path = os.path.join(os.getcwd(), - f"{file_name}.txt") # Use the provided file name in the project root + file_path = os.path.join(os.getcwd(), f"{file_name}.txt") - # Create the directories if they don't exist os.makedirs(os.path.dirname(file_path), exist_ok=True) - # Check if the file path exists if not os.path.exists(os.path.dirname(file_path)): - raise FilePathNotFoundException( - f"The specified file path does not exist: {os.path.dirname(file_path)}") + raise FilePathNotFoundException(f"The specified file path does not exist: {os.path.dirname(file_path)}") - # Set the default max_file_size if not provided max_file_size = max_file_size or self.default_max_file_size - - # Convert max_file_size to bytes max_file_size_bytes = max_file_size * 1024 * 1024 - # Check if the file exists file_exists = os.path.exists(file_path) - # Check if the file size limit is reached if max_file_size and file_exists and os.path.getsize(file_path) >= max_file_size_bytes: if auto: - # Auto-delete log file data by truncating the file with open(file_path, 'w'): pass else: - # Find the next available file name with a number appended file_base, file_ext = os.path.splitext(file_path) count = 1 while os.path.exists(f"{file_base}_{count}{file_ext}"): count += 1 file_path = f"{file_base}_{count}{file_ext}" - # Open the file in appended mode, creating it if it doesn't exist with open(file_path, "a" if file_exists else "w") as log_file: log_file.write(log_message_without_color + "\n") @@ -255,192 +293,218 @@ def _log(self, level, key, value, color=None, log_to_file=True, file_path=None, except Exception as e: raise FileCreationError(f"Error creating or writing to the log file: {e}") + return self.remove_color_codes(log_message) # Return log message without color formatting + def log_function(self, level, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a message with exception handling. - - Parameters: - - level (str): Log level (e.g., "INFO", "ERROR"). - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ + General logging function that handles different log levels (INFO, WARNING, ERROR, etc.). + + Args: + level (str): The log level (e.g., "INFO", "WARNING", "ERROR", etc.). + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ if value is None: - # If only one parameter is provided, consider it as the value, and set key to None key = None value = key_or_value else: - # If two parameters are provided, consider the first as the key and the second as the value key = key_or_value - self._log(level, key, value, color, log_to_file, file_path, file_name, max_file_size, auto, show_time, - color_enabled) + return self._log(level, key, value, color, log_to_file, file_path, file_name, max_file_size, auto, show_time, + color_enabled) def info(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a message with the INFO level. - - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("INFO", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Logs an informational message. + + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("INFO", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def warn(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a message with the WARNING level. + Logs a warning message. - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("WARNING", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("WARNING", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def error(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a message with the ERROR level. + Logs an error message. - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("ERROR", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("ERROR", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def debug(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a message with the DEBUG level. + Logs a debug message. - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("DEBUG", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("DEBUG", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def critical(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a critical message. - - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("CRITICAL", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, - auto, - show_time, color_enabled) + Logs a critical message. + + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("CRITICAL", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, + auto, show_time, color_enabled) def fatal(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a fatal message. + Logs a fatal error message. - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("FATAL", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("FATAL", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def trace(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log a trace message. + Logs a trace message. - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("TRACE", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("TRACE", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) def log(self, key_or_value, value=None, color=None, log_to_file=True, file_path=None, file_name=None, max_file_size=None, auto=True, show_time=None, color_enabled=None): """ - Log an info message. - - Parameters: - - key_or_value (str): If a second parameter (value) is provided, this is considered as the key. - If no second parameter is provided, this is considered as the value, and the key is set to None. - - value (str, optional): The value of the log message. Defaults to None. - - color (str, optional): ANSI color code for the log message. Defaults to None. - - log_to_file (bool, optional): Whether to log to a file. Defaults to True. - - file_path (str, optional): File path for logging. Defaults to None. - - file_name (str, optional): File name for logging. Defaults to None. - - max_file_size (int, optional): Maximum file size for logging. Defaults to None. - - auto (bool, optional): Whether to auto-delete log file data when the size limit is reached. Defaults to True. - - show_time (bool, optional): Whether to include timestamps in the log message. Defaults to None. - """ - self.log_function("LOG", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, - show_time, color_enabled) + Logs a general message. + + Args: + key_or_value (str): The key or message to log. + value (str, optional): Additional message value for the log. + color (str, optional): Color to use for the log message. + log_to_file (bool, optional): Whether to log to a file (default is True). + file_path (str, optional): Path where the log file will be stored (default is None). + file_name (str, optional): Custom log file name (default is None). + max_file_size (int, optional): Maximum file size before rolling over (in MB). + auto (bool, optional): Automatically handle file rollover (default is True). + show_time (bool, optional): Whether to include timestamp in the log message (default is None). + color_enabled (bool, optional): Whether to enable colored output (default is None). + + Returns: + str: The log message with or without color, depending on the configuration. + """ + return self.log_function("LOG", key_or_value, value, color, log_to_file, file_path, file_name, max_file_size, auto, + show_time, color_enabled) diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..9eb9abd --- /dev/null +++ b/poetry.lock @@ -0,0 +1,140 @@ +# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand. + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +groups = ["main"] +markers = "python_version < \"3.11\"" +files = [ + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "packaging" +version = "24.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pytest" +version = "8.3.4" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=1.5,<2" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} + +[package.extras] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "tomli" +version = "2.2.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.8" +groups = ["main"] +markers = "python_version < \"3.11\"" +files = [ + {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, + {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, + {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, + {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, + {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, + {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, + {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, + {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, + {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, + {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, +] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.8" +content-hash = "95c6f7c26eb58dd7f94c2684c5aae696a4aeb5b4a4911481a18022651ca73cad" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fc4be22 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,47 @@ +[project] +name = "logly" +version = "0.0.7" +description = "Logly: Ready to Go Python logging utility with color-coded messages, file-based logging, and many more customizable options. Simplify logging in your Python applications with Logly." +authors = [{name = "Muhammad Fiaz", email = "contact@muhammadfiaz.com"}] +maintainers = [{name = "Muhammad Fiaz", email = "contact@muhammadfiaz.com"}] +keywords = ["logging", "custom-log", "logly", "logging-utility", "python","logs"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: System :: Logging", +] + +license = { file = "LICENSE" } +readme = "README.md" +homepage = "https://github.com/muhammad-fiaz/logly.git" +repository = "https://github.com/muhammad-fiaz/logly.git" +documentation = "https://github.com/muhammad-fiaz/logly#readme" + +[tool.poetry.dependencies] +python = ">=3.8" +pytest = "8.3.4" +packaging = "24.2" +colorama = ">=0.4.4" + +[poetry.group.dev.dependencies] +pytest-runner = "*" +poetry-plugin-export = "^1.9.0" + +[tool.poetry.scripts] +logly = "logly:Logly" + +[tool.poetry.urls] +bug-tracker = "https://github.com/muhammad-fiaz/logly/issues" +source-code = "https://github.com/muhammad-fiaz/logly.git" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + diff --git a/requirements.txt b/requirements.txt index e8fce65..a823eaa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,51 @@ -colorama>=0.4.6 -pytest>=7.4.3 -setuptools>=69.0.2 \ No newline at end of file +colorama==0.4.6 ; python_version >= "3.8" \ + --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ + --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 +exceptiongroup==1.2.2 ; python_version < "3.11" and python_version >= "3.8" \ + --hash=sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b \ + --hash=sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc +iniconfig==2.0.0 ; python_version >= "3.8" \ + --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ + --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374 +packaging==24.2 ; python_version >= "3.8" \ + --hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \ + --hash=sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f +pluggy==1.5.0 ; python_version >= "3.8" \ + --hash=sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1 \ + --hash=sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669 +pytest==8.3.4 ; python_version >= "3.8" \ + --hash=sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6 \ + --hash=sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761 +tomli==2.2.1 ; python_version < "3.11" and python_version >= "3.8" \ + --hash=sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6 \ + --hash=sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd \ + --hash=sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c \ + --hash=sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b \ + --hash=sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8 \ + --hash=sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6 \ + --hash=sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77 \ + --hash=sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff \ + --hash=sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea \ + --hash=sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192 \ + --hash=sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249 \ + --hash=sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee \ + --hash=sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4 \ + --hash=sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98 \ + --hash=sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8 \ + --hash=sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4 \ + --hash=sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281 \ + --hash=sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744 \ + --hash=sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69 \ + --hash=sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13 \ + --hash=sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140 \ + --hash=sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e \ + --hash=sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e \ + --hash=sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc \ + --hash=sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff \ + --hash=sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec \ + --hash=sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2 \ + --hash=sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222 \ + --hash=sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106 \ + --hash=sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272 \ + --hash=sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a \ + --hash=sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7 diff --git a/setup.py b/setup.py index 0490a28..fa732a8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = "0.0.6" +VERSION = "0.0.7" DESCRIPTION = 'Logly: Ready to Go Python logging utility with color-coded messages, file-based logging, and many more customizable options. Simplify logging in your Python applications with Logly.' @@ -18,16 +18,19 @@ url='https://github.com/muhammad-fiaz/logly.git', packages=find_packages(), keywords=[ - 'log', 'logging', 'logly', 'python' + "logging", "custom-logging", "logly", "logging-utility", "python", "logs" ], classifiers=[ - "Development Status :: 1 - Planning", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: Unix", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: System :: Logging", ], python_requires='>=3.8', install_requires=[