Skip to main content

Simple logger to have fancy logs :D

Project description

Python-Logger

Logger for python that can write into stdout, create a log file at the end.

Usage

Output file

The output file can be in 2 formats: .html or .log To change this, you have a parameter in the constructor:

    l = Logger(html=True)

By default, the html mode is ON.

Note: HTML log files take a bit more space, so if you generate many logs, consider using .log files

Colors

There are multiple colors available, you can use them using Colors.

Types of log

  • log, normal logs

  • warn

  • error

  • debug, can be disabled with parameter self.debug (debug=False in constructor)

  • success

  • failed

Layout functions

  • section, create a separation to arrange your logs
................................. SECTION .................................
  • cadre, create a rectangle with text inside
################################################################################
#                                                                              #
#                                                                              #
#                                    CADRE                                     #
#                                                                              #
#                                                                              #
################################################################################

Macros

  • init, Create a cadre and start timer
  • end, stop timer, create a last log with total duration and save into file

Waiters

There are some waiters to track your process progress:

  • waiting_time: print the running time of a process
My message 4h 2min 42sec
  • waiting_animation: print an animated wheel next to a custom message for a duration
[/] My message
  • progress_bar: display a loading bar with a given advencement (ex: 0.42 stands for 42%)
[11%] [■■■■■.............................................]

Example

Here is a code exampleto show posibilities

    l = Logger(debug=False)
    l.init(msg="Logger Pauwels demonstration")
    l.log("Testing log system")
    l.section("Progress bar", char=".", color=Colors.YELLOW)

    steps = 200
    duration = 5    # In seconds
    for i in range(steps):
        l.progress_bar(i/steps, color=Colors.CYAN)
        time.sleep(duration / steps)

    l.success("Loading bar: OK")

    l.section("Waiting time", color=Colors.PINK)

    for i in range(steps):
        elapsed_time = duration*i/steps + 60
        l.waiting_time(elapsed_time)
        time.sleep(duration / steps)

    l.success("Waiting ended")
    l.debug("Debug message")
    l.warn("Warning message")
    l.error("Error message")
    l.fail("Fail message")


    l.cadre("Thanks for using me :D", color=Colors.RED)

    l.print_rainbow("For any problem, contact me: tom.j.pauwels@gmail.com")

    l.end()

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

logger_pauwels-0.1.8.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

logger_pauwels-0.1.8-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file logger_pauwels-0.1.8.tar.gz.

File metadata

  • Download URL: logger_pauwels-0.1.8.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for logger_pauwels-0.1.8.tar.gz
Algorithm Hash digest
SHA256 98e8deefc3f073536936c80e590ea1930798e2ba18d57ad2c484a9441a9d4702
MD5 e7716f1dd2c0c9234510393b3808ea80
BLAKE2b-256 afd11f86170c31b67410cd54c45b178e3e7c93b3cb612fe67f0bf843ff3f37ab

See more details on using hashes here.

File details

Details for the file logger_pauwels-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: logger_pauwels-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for logger_pauwels-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8929f8c58c59c614ace839a81f3fc06055801a3e675b4021b903d4f33af859d3
MD5 197ad2d61891b25599de44ff9cc79576
BLAKE2b-256 162aadebc6911acd94426061a0d083a511cef504ce1503a7198e8054ec412322

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