Skip to main content

A Nicely formatted Logger for the Cosmo Project

Project description

Cosmo Logger

A Simple yet Nicely formatted Logger for all your Logging Needs. Made for the Cosmo Project

Key Features

  • Simple to Use.
  • Supports Colors
  • Configurable Styles

Installation

You can install via python's pip module:

Install with Offical Python Package Index:

python3 -m pip install cosmologger

or with this Git Respiratory

python3 -m pip install git+https://github.com/SamHDev/cosmologger.git

Note for Noobies: If python3 work then use python

Usage

Importing the Library

You can import the library with the following statement:

import cosmologger
Creating a Logging Object

To Start logging, create a logger object. This can be placed in the module or in a class so it can be accessed around the project.

logger = cosmologger.Logger()

The Logger Object can be created with options such debug and app_name as shown below:

logger = cosmologger.Logger(
    debug = True,             # Enables Debug Print
    app_name = "CORE APP",    # Set App Name to Print
    style = None,             # Set Style Formating (Format Dict)
    color = None              # Enable Color Print
)
Logging Example

To output messages to the logger/console you can call the many functions found in the Logger Class.

Here is a simple Example of each Method.

logger.info("This a 'Info' Message")
logger.ok("This a 'Ok' Message")
logger.warn("This a 'Warn' Message")
logger.error("This a 'Error' Message")
logger.fatal("This a 'Fatal' Message")
logger.debug("This a 'Debug' Message")
logger("This a 'Debug' Message but Simpler")
logger.log("TEST", "This is a Custom Logging Output Type")

The above code would produce the resulting output:

main>  10:03:18 [INFO] This a 'Info' Message
main>  10:03:18 [-OK-] This a 'Ok' Message
main>  10:03:18 [WARN] This a 'Warn' Message
main>  10:03:18 [ERRR] This a 'Error' Message
main>  10:03:18 [FATAL] This a 'Fatal' Message
main>  10:03:18 [Debug] This a 'Debug' Message
main>  10:03:18 [Debug] This a 'Debug' Message but Simpler
main>  10:03:18 [TEST] This is a Custom Logging Output Type
Logging Methods
Type Output Methods
Info [INFO] Logger.info(msg)
Ok [-OK-] Logger.ok(msg)
Warning [WARN] Logger.warn(msg) Logger.warning(msg)
Error [ERROR] Logger.error(msg)
Fatal [FATL] Logger.fatal(msg) Logger.critical(msg)
Debug [DBUG] Logger.debug(msg) Logger(msg)
Custom Logging

Custom Logging Types is a simple as so:

logging.log("Custom Type", "Message")
Sub Loggers (For Multiple Classes/Modules)

A SubLogger can be used for classes/modules across large projects. The cosmoLogger.SubLogger is a subclass of cosmoLogger.Logger and contains all the methods However, the class requires the app_name parameter and has the optinal parent paramater that copies the settings from the 'parent' Logger Object.

It can be used like so:

sublogger = logger.SubLogger("SUB APP", parent=logger)

License and Attributes

Created by Sam Huddart under alias SamHDev for the Blume Open Source Project. SamHDev/cosmologger is licensed under the GNU General Public License v3.0 and is Open-Source as seen in LICENSE. Commercial use, Modification and Distribution are permmited. Although credit is not necessary, it is much obliged. If you do wish to credit the author, please link the respiratory and the author at github or website. Thank you for using our work.

Project details


Download files

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

Source Distribution

cosmologger-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosmologger-1.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file cosmologger-1.0.0.tar.gz.

File metadata

  • Download URL: cosmologger-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for cosmologger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 75048477d4af3e1c4edc0a1eb6b444c6ad170148ce5fcda186c3493ca6c2605d
MD5 50e472dfea95f1c922d4ed78de826878
BLAKE2b-256 0ec6efe80d11176d510ac80a32f28521eee6445c4332a728f4369fd38ad9b827

See more details on using hashes here.

File details

Details for the file cosmologger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cosmologger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for cosmologger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d606b0792c91fdf3c64531fa624f3f73db67ac53fc82c2a827c3d8ddb17f8d61
MD5 b4bc769b072def847fca328b1bd01f94
BLAKE2b-256 41b84c44222e864f915b82a613d7592ef2ca97c92a73d1360435194a52826e71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page