
Get rid of the log4j
based logging module, become a better debugger.
Explore the docs »
Report Bug
Request Feature
PyLog
is a Pythonic logging module designed to address the common complaints of the built-in logging
module. It simplifies the logging process by providing a more intuitive configuration system, built-in context support, a flexible design, and a more Pythonic API. Additionally, PyLog
offers better defaults, easier JSON logging, and improved debugging and introspection capabilities, making it easier to manage and maintain your application's logs.
Here's why PyLog is a game-changer:
- Your time should be focused on crafting a better debugging experience. PyLog simplifies the logging process, allowing you to focus on what matters most.
- You shouldn't be bogged down by tedious logging configurations. PyLog's intuitive configuration system and built-in context support streamline your workflow.
- You should be able to easily manage and maintain your application's logs. PyLog's flexible design, Pythonic API, and improved debugging capabilities make it easier to do just that.
Of course, PyLog is designed to be adaptable to different project needs. If you have suggestions for improvements or additional features, please fork this repo and create a pull request or open an issue. I appreciate any and all contributors.
PyLog
was choosen to be written in pure-python, rather than some other flavour, or even creating a module in C. This is mainly due to the fact that the libary is generally simple and doesn't require "insanely fast build times".
I personally choose 3.13.2t due to the fact it is the most recent release version. I will be backporting PyLog to atleast 3.10.x, and may go even further in the future.
If you don't have Python installed, follow these steps to install Python and Pip:
- Install Python: Go to the Python download page and follow the installation instructions for your operating system.
- Install Pip: Pip is usually installed with Python. If not, you can install it by following the instructions on the Pip installation page.
If you prefer to use Conda, you can install Python and Pip using Conda:
- Install Conda: Go to the Conda download page and follow the installation instructions for your operating system.
- Create a new Conda environment: Open a terminal or command prompt and run
conda create --name myenv python=3.8
. - Activate the Conda environment: Run
conda activate myenv
. - Install Pip: Pip is usually installed with Python. If not, you can install it by running
conda install pip
.
Once you have Python and Pip installed, you can install the pylog
module using Pip:
python3 -m venv myenv
source myenv/bin/activate
pip install pythonlog
After installation, you can use pylog
in your Python projects.
Here is a quick snippet of how to use PyLog, it really is that simple:
from pylog import logger
from pylog._enums import Levels
# Configure the logger with a custom format and output
logger.change(
output="app.log", # Log output to a file named "app.log"
level=Levels.INFO, # Set the logging level to INFO
format="<green>{timestamp}<reset> - <blue>{level}<reset>: {message}" # Define a log format with colors
)
# Log messages at different levels
logger.debug("This is a DEBUG message.") # This won't appear because the level is set to INFO
logger.info("This is an INFO message.") # This will appear
logger.warning("This is a WARNING message.") # This will appear
logger.error("This is an ERROR message.") # This will appear
logger.critical("This is a CRITICAL message.") # This will appear
For more examples, please refer to the Documentation
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See MIT License for more information.
Brody Critchlow - @thornily - brody@playprodix.com
Project Link: https://github.com/brodyritchlow/pylog