Skip to content

Ever wanted a simple solution to the obviously clunky and over engineered built-in logging module in Python? Look no further, PyLog provides a simple pythonic way for logging.

Notifications You must be signed in to change notification settings

brodycritchlow/PyLog

Repository files navigation


Logo

PyLog

Get rid of the log4j based logging module, become a better debugger.

Explore the docs »

Report Bug Request Feature

About The Project

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.

Built With

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.

Installation

If you don't have Python installed, follow these steps to install Python and Pip:

  1. Install Python: Go to the Python download page and follow the installation instructions for your operating system.
  2. 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:

  1. Install Conda: Go to the Conda download page and follow the installation instructions for your operating system.
  2. Create a new Conda environment: Open a terminal or command prompt and run conda create --name myenv python=3.8.
  3. Activate the Conda environment: Run conda activate myenv.
  4. 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.

Usage

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

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See MIT License for more information.

Contact

Brody Critchlow - @thornily - brody@playprodix.com

Project Link: https://github.com/brodyritchlow/pylog

Acknowledgments

About

Ever wanted a simple solution to the obviously clunky and over engineered built-in logging module in Python? Look no further, PyLog provides a simple pythonic way for logging.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages