Skip to main content

Package to print out messages to user.

Project description

Overview

The purpose of this library is to provide a logger for my other projects. It also is acting as a learning process for publishing a python module.

Messages Package

This is a package that can be included in projects to output messages

Example logging REPO: https://github.com/srtamrakar/python-logger/tree/master

Repository structure

run 'tree' at the top of the repo:
.
├── CHANGELOG.md
├── LICENSE
├── README.md
├── pyproject.toml
├── requirements.txt
├── setup.py
├── src
│   ├── demo.py
│   └── phootlogger
│       ├── __init__.py
│       └── logger.py
└── tests
    └── phootlogger
        └── test_logger.py

Installation Process:

#=======================
# 1. Write the module
#=======================
# Follow this tutorial: https://packaging.python.org/en/latest/tutorials/packaging-projects/

# Required files:
#   setup.py
#   LICENSE
#   README

#=======================
# 2. Build module
#=======================
$ python3 -m pip install --upgrade build
$ python3 -m build

#=======================
# 3. Upload module to pypi to be installed
#=======================
# Make sure twin is installed
$ python3 -m pip install --upgrade twine

# Upload to test server ( https://test.pypi.org/project/phootlogger/ ):
$ python3 -m twine upload --repository phootlogger-test dist/* --verbose

# Upload to real server ( https://pypi.org/project/phootlogger/ ):
$ python3 -m twine upload --repository phootlogger dist/* --verbose

#=======================
# 4. Install the module:
#=======================
# Test Installation
$ python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps phootlogger

# Real installation
$ python3 -m pip install phootlogger

Testing

Unit Tests

# From the top level directory, run the command
$ pytest --cov=src/. tests/

Running the demo

# A demo file can be found in src/demo.py

# To run it and see examples of the feature, run the following
$ python demo.py

# ==========================================
# Output:
# ==========================================
# ==========================================
# Start of Nominal Demo
# ==========================================
#
# 2025-08-22 18:48:11.150962 : Test.nominal_demo         : [ERROR]   : Error message here.
# 2025-08-22 18:48:11.151044 : Test.nominal_demo         : [WARNING] : Warning message here.
# 2025-08-22 18:48:11.151064 : Test.nominal_demo         : [INFO]    : Info message here.
# 2025-08-22 18:48:11.151085 : Test.nominal_demo         : [DEBUG]   : Debug message here.
#
# ==========================================
# Start of Showing/Hiding Fields Demo
# ==========================================
#
#
# ------------------------------------------
# No fields hidden.
# ------------------------------------------
# 2025-08-22 18:48:11.151110 : Test.hiding_fields_demo   : [ERROR]   : Error message here.
# 2025-08-22 18:48:11.151117 : Test.hiding_fields_demo   : [WARNING] : Warning message here.
# 2025-08-22 18:48:11.151122 : Test.hiding_fields_demo   : [INFO]    : Info message here.
# 2025-08-22 18:48:11.151129 : Test.hiding_fields_demo   : [DEBUG]   : Debug message here.
#
# ------------------------------------------
# Timestamps hidden.
# ------------------------------------------
# Test.hiding_fields_demo   : [ERROR]   : Error message here.
# Test.hiding_fields_demo   : [WARNING] : Warning message here.
# Test.hiding_fields_demo   : [INFO]    : Info message here.
# Test.hiding_fields_demo   : [DEBUG]   : Debug message here.
#
# ------------------------------------------
# Source ( class/method name ) Hidden.
# ------------------------------------------
# 2025-08-22 18:48:11.151215 : [ERROR]   : Error message here.
# 2025-08-22 18:48:11.151219 : [WARNING] : Warning message here.
# 2025-08-22 18:48:11.151223 : [INFO]    : Info message here.
# 2025-08-22 18:48:11.151227 : [DEBUG]   : Debug message here.
#
# ------------------------------------------
# Source and Timestamps Hidden.
# ------------------------------------------
# [ERROR]   : Error message here.
# [WARNING] : Warning message here.
# [INFO]    : Info message here.
# [DEBUG]   : Debug message here.
#
# ------------------------------------------
# Owner Shown.
# ------------------------------------------
# 2025-08-22 18:48:11.151252 : /example/path/to/phootlogger/src/demo.py : Test.hiding_fields_demo   : [ERROR]   : Error $ message here.
# 2025-08-22 18:48:11.151257 : /example/path/to/phootlogger/src/demo.py : Test.hiding_fields_demo   : [WARNING] : Warning $ message here.
# 2025-08-22 18:48:11.151260 : /example/path/to/phootlogger/src/demo.py : Test.hiding_fields_demo   : [INFO]    : Info $ $ message here.
# 2025-08-22 18:48:11.151264 : /example/path/to/phootlogger/src/demo.py : Test.hiding_fields_demo   : [DEBUG]   : Debug $ message here.
#
# ==========================================
# Start of Deprecation Demo
# ==========================================
#
# *****************************************************************
# * WARNING:
# *       This class has been DEPRECATED. It's name has been changed to "Logger".
# *       This specific instance will soon no longer work.
# *****************************************************************
# 2025-08-22 18:48:11.156938 : Test.deprecation_demo     : [ERROR]   : error message here.
# WARNING. The method 'system' will soon DEPRECATED.
# 2025-08-22 18:48:11.160526 : Test.deprecation_demo     : [INFO]    : normal message here.
#
# ==========================================
# Start of Quit Script Demo
# ==========================================

Questions:

setup.cfg:

setup.py:
    Instructions to build software. Maybe some configuration options like computing test coverage or unit tests or
    the install prefix.

pyproject.toml:
    Specifies the project's metadata.
    Used to replace .cfg, but formats everything in TOML. ( Tom's Obvious, Minimal Language: https://en.wikipedia.org/wiki/TOML )
    You can put "Abstract Dependencies" here, but not pinned dependencies. Pinned ones belong in the requirements.txt

requirements.txt:
    Not the same thing as setup.cfg. Needed for a different reason. This is typically used for deployment with
    version pinned dependencies. The reason is so you don't get the latest and greatest, and only get the version
    you know you have explicitly tested.

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

phootlogger-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

phootlogger-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file phootlogger-0.1.0.tar.gz.

File metadata

  • Download URL: phootlogger-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for phootlogger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf430ca8e09b7e6c7dbf18b6deb91b1d54776eb1c7428f698d00bbd3f0cc7771
MD5 18ea682767e856991bef8747edfa084e
BLAKE2b-256 1b97745367ba56d36da36dc46003d930627772bd4c9d8a697f48b392310ef907

See more details on using hashes here.

File details

Details for the file phootlogger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: phootlogger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for phootlogger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21c15655b5e07909d98bebc9e8971bc93bfac02729ca1c0a533ece3c4254ea43
MD5 0e091756105067b251199a2378ce444a
BLAKE2b-256 6a307a4ffd0f9a2b651bcc201c6f19f1b1740d96eb9b7ff23defd6ab6a3ffb3d

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