Skip to main content

The simplest Python logger for everyday tasks.

Project description

loggerpy

The simplest Python logger for everyday tasks.

Table of Contents

Installation

The easiest way to install is throw pip.

pip install loggerpy

Instructions

In order to use this simple logger, many examples are provided inside examples directory

logging

Configuration

The main classes of the loggerpy package are Logger and Level.

from loggerpy import Logger, Level

The Logger class is a Singleton, so you can recall the __init__ method through Logger() and the same instance will always be returned.

logger = Logger()

The possible customization of the logger instance are:

  • name: the name of all loggers
  • folder: the path of saving log if you want to save them
  • print_level: the minimum level of printing
  • save_level: the minimum level of saving, they can be different

In order to simplify the customization of printing and saving level it is provided a class that contained the 6 possible levels of logging. Importing Level from loggerpy, they can be used eg Level.DEBUG or Level.WARNING

  • Level.NO_LOGGER
  • Level.DEBUG
  • Level.INFO
  • Level.WARNING
  • Level.ERROR
  • Level.CRITICAL

The path can be set as absolute or relative. If the path is an absolute path it is used directly, otherwise it put after the project path. The default value is the project path

 E.g.
 Relative path
 -------------
 >>> logger.folder = 'relative_path'
 In this case the used path is:
 > /path/to/the/project/relative_path

 Absolute path
 -------------
 >>> logger.folder = 'absolute_path'
 It is setted as global path
 > /absolute_path/

Configuration example

Logger

Now, it's time to create your first logger.

from loggerpy import Logger

logger = Logger()
logger.name = "First logger"

First logger example

Customization

The parameters of the Logger class can be set all in one time.

logger.configure(name="Name", log_folder="path/to/log/folder", print_level=Level.DEBUG, save_level=LEVEL.WARNING)

An example

Versions

stable version

  • 1.0 :

    • first release
  • 1.1 :

    • rewritten the input path of saving log in configure() and get_logger()
    • configuration works properly for all file of your project
  • 2.0 :

    • Logger is now a Singleton
    • Level is an enum

NextFeatures

  • [ ] custom format for timestamp
  • [ ] custom format for all log
  • [ ] custom color for each level

License

This project is under the GPL-3.0 license - see the LICENSE.md file for more details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for loggerpy, version 2.1.1
Filename, size File type Python version Upload date Hashes
Filename, size loggerpy-2.1.1-py3-none-any.whl (18.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size loggerpy-2.1.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page