New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

printinglog

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

printinglog

Python logging instead of complicated print

  • 0.0.1
  • PyPI
  • Socket score

Maintainers
1

Simple Logging Module

I've been using pythons built-in logging for my previous projects, but i discovered that it doesn't work as expected when running cronjobs in docker containers. The logger fails to write to the specified file because cronjobs operate in a limited environment with different permissions. They often capture standard output and error to a default file, usually cron.log in my case. While there might be ways to fix this, as a coder, it feels much better to write my own logging module; it would be a disgrace otherwise. So with this module, i can read the logs from cron.log since it uses print statements with logging formatting.

Install

Install the module with:

pip install printinglog

Usage

To start using printinglog, initialize the logger with:

from printinglog import Logger

logger = Logger()

logger.info("This is a INFO log")

You can also change how much detail you want to show in your log:

logger = Logger(format="simple")
logger.info("This is a INFO log")
>> INFO: This is a INFO log

logger = Logger(format="logging")
logger.info("This is a INFO log")
>> 2024-07-26 22:55:28 - INFO: This is a INFO log

logger = Logger(format="detailed")
logger.info("This is a INFO log")
>> 2024-07-26 22:55:28 @main - INFO: This is a INFO log

logger = Logger(format="long")
logger.info("This is a INFO log")
>> INFO: This is a INFO log
2024-07-26 22:55:28 @main<test_function> - INFO: This is a INFO log

To change the colors for each log type, you can also specify that:

default_colors = {
    "info": "green",
    "error": "red",
    "warning": "yellow",
    "debug": "blue",
}
logger = Logger(colorscheme=default_colors)

Colors to choose from:

  • black
  • red
  • green
  • yellow
  • blue
  • magneta
  • cyan
  • white

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc