Skip to main content

Draw primitives and save your logs!

Reason this release was yanked:

For some reason using logging functionality needs [graph] installled

Project description

LogNGraph

A Python 3.12 package for easily drawing primitives and saving log files

Functionality

⚠️ You're entering WIP territory ⚠️

Logs

  1. Create Logger instance:
    from logngraph.log import get_logger
    from logngraph.log.levels import *
    logger = get_logger(__name__, filename="my_log_file.txt", level=TRACE)  # Look for everything
                                                          # By default, log level is INFO
    

    ⚠️ get_logger parameters: ⚠️

    • name: Name of the module/logger
    • filename: Filename of the log file
    • level: Logging level
    • file_colors: If True, will write colorful text to the log file. (Can not be colorful in some editors)
    • force_write: If True, write logs to the log file (if not None), even if level is higher.
  2. Then just log!
    logger.trace("When you need to know EVERY detail")
    logger.debug("Diagnosing or troubleshooting an issue")
    logger.info("Something has happened, e.g. started a server")
    logger.warn("Something unexpected has happened,"
                " but code will continue running")
    logger.error("App hit an issue that prevents a certain "
                 "function from working, e.g. payment system is offline"
                 "but the program can still continue running")
    logger.fatal("Something crucial has stopped working, e.g"
                 "lost connection to the main server, can't"
                 "continue running")
    

That's it! You can also change the log level:

logger.set_level(WARNING)
# WARNING was imported earlier from logngraph.log.levels

⚠️ Here's a hierarchy of log levels: ⚠️

  • TRACE - e.g. what packets client received from the server
  • DEBUG - e.g. game server froze, and you need to see why
  • INFO - e.g. someone said something in chat, and you saved it in logs
  • WARNING - e.g. lost connection to the server temporarily
  • ERROR - e.g. lost connection to the server completely (timeout, etc.)
  • FATAL - e.g. client could not find models for the characters
  • NONE - e.g. you don't want logs ¯\_(ツ)_/¯

⚠️ Write to file happens when one of the log methods is called ⚠️

Graphics

  1. Create a Window instance:
    from logngraph.graph import Window
    window = Window("My title", "800x800", resizable=True)
    
  2. Draw primitives:
    window.fill("#000000")  # fills whole window with color
    window.rect(0, 0, 100, 100, color="#777777")
    window.rect((10, 10), (250, 50), color="#ff00ff")   # or like this
    window.circle(25, 20, 15)   # at (25, 20) with radius 15
    window.ellipse(0, 0, 80, 100)  # from (0, 0) to (80, 100)
    window.line(0, 0, 800, 900, color="#0000ff")
    window.polygon(750, 750, 800, 400, 35, 600, color="#ff0000")
    # Also you can display text!
    window.write(60, 150, text="Hello, World!", color="#ffffff", bg_color="#000000", antialias=True, size=32, font="Arial")
    
  3. And update the screen:
    window.update()
    
    ⚠️ And if doing this in loop don't forget to window.handle_quit()! ⚠️
  4. You can also save the screen:
    window.screenshot("screenshot.png")
    

That's all!

Installation

Use pip:

# without graphics
pip install logngraph
# with graphics
pip install logngraph[graph]

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

logngraph-0.0.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

logngraph-0.0.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file logngraph-0.0.3.tar.gz.

File metadata

  • Download URL: logngraph-0.0.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for logngraph-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2b7fbb02af716b9a13b8cbcec6a8a9e39ff303763ff9e9dd5c557858e5d7b206
MD5 997a1085c74d6fa903d23509cab65d4f
BLAKE2b-256 f013440dbfb00434393384be17dfa6c8968a57b2ac8eec1d62e6fe4beb4b34f8

See more details on using hashes here.

File details

Details for the file logngraph-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: logngraph-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for logngraph-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f24b1e8493d29abb847447e43f4c56ba07cc07ea0b28b5d68fd6af2cfd69b038
MD5 b0d2fcce7082266bc87687b41dbca0ff
BLAKE2b-256 de73aa018c5c1a0dab4831c0f35dbb932cb1cc7a00b10060813f363274bc109c

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