Skip to main content

Log and Print

PyPI version License Downloads

A simple logging package that helps you to log what is happening in your application.

Installation

You can install Log and Print using pip:

pip install logandprint

Usage

To start logging it is as simple as importing the logandprint object and issuing the logging commands:

write, info, error, success, warning, debug

To logging a message to the log:

import logandprint as log

log.write("This is a common log message")
log.info("This is log information, it appears blue in the terminal")
log.error("This is an error message, it appears red in the terminal")
log.success("This is a success message, it appears green in the terminal")
log.warning("This is a warning message, it appears yellow in the terminal")
log.debug("This is a debug message, it appears white in the terminal")

The write, info, error, success, warning methods accept two parameters, the message and the console flag (boolean) to display or not the message in the terminal.

In the debub method, messages will only be displayed in the terminal if debug mode is active log.debugMode(True)

setLogFile

By default, the log is saved in the log.log file in the current directory. But you can change the log file by using the setLogFile function.

log.setLogFile("./logs/myLogFile.log")

setMaxFileSize

By default, the log file is rotated once it reaches 2,000,000 bytes (2MB), or when the day changes. You can change the maximum size (in bytes) with setMaxFileSize.

log.setMaxFileSize(10000000)  # 10MB

setBackupCount

When the log file is rotated, by default 1 backup is kept (myLogFile.log.bak1). You can change how many backups are kept with setBackupCount. Older backups are shifted (.bak1 -> .bak2, and so on) and the oldest one beyond the configured count is discarded.

log.setBackupCount(3)  # keeps myLogFile.log.bak1, .bak2 and .bak3

Set it to 0 to disable backups entirely: the log file is simply cleared on rotation instead of being kept, which is the fastest option if you don't care about old logs.

log.setBackupCount(0)

debugMode

The log packet will not be printed to the console. You can change this by setting debugMode to True.

log.debugMode(True)

To stop printing to the console, change the debugMode setting to False. Don't worry, the log file will still be writing.

log.debugMode(False)

enable

To disable the log you can call the enable function and set it to False.

log.enable(False)

And to enable it again you can call the enable function and set it to True.

log.enable(True)

export_to_csv

You can export the log to a csv file by calling the export_to_csv function.

log.export_to_csv("./logs/myLogFile.csv")

Author

  • Guilherme Saldanha

This software is free to use and distribute. You can use it for any purpose, but please give credit to the original author.

For more info see LICENSE file.

Metadata

Release files for logandprint 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logandprint 1.3.2
File Size Uploaded Provenance Actions
logandprint-1.3.2.tar.gz 7.5 kB Without provenance Details for logandprint-1.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for logandprint 1.3.2
File Interpreter ABI Platform Actions
logandprint-1.3.2-py3-none-any.whl Python 3 none any Details for logandprint-1.3.2-py3-none-any.whl

Total release size: 14.2 kB

Release files / logandprint-1.3.2.tar.gz

Download URL logandprint-1.3.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fbe8f258330665aee93d5916daad19970d6a3d5b87ab363e5e8cdb7af239113f
BLAKE2b-256 checksum
How to use checksums
aef74c106f4d1e4fa1ed64dc5dd2a1edc185e9b53e9e496b452dda52470d913f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / logandprint-1.3.2-py3-none-any.whl

Download URL logandprint-1.3.2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1b0d566df5be1ba010599c3754c1e2fe6a73a802c002cf4aad2bff198cf5a0c
BLAKE2b-256 checksum
How to use checksums
c1d71eceb36a1346e66ee5869c9b94c9f6e985f3f3b7c68b4fedd53692c1527b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for logandprint 1.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page