Skip to main content

Draw primitives and save your logs!

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_level: Like level, but for file. If None, will be the same as level.

    • file_colors: If True, will write colorful text to the log file. (Can not be colorful in some editors)

  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:

from logngraph.log.levels import *
logger.set_level(WARNING)
logger.set_file_level(INFO)

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 (disabled)

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(title="Window title", width=800, height=800, resizable=True)
  2. Draw primitives:

    window.fill("#000000")  # fills whole window with color
    window.rect((10, 10), (250, 50), color="#ff00ff")  # from (10, 10) with width, height (250, 50)
    window.circle((25, 20), 15)   # at (25, 20) with radius 15
    window.line((0, 0), (800, 900), color="#0000ff")  # from (0, 0) to (800, 900)
    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")
    # And, you can rotate and translate!
    window.translate(500, 100)
    # Now (0, 0) is (500, 100) for new primitives you want to draw!
    window.rotate(45)  # degrees
    # Now everything after this will be rotated 45 degrees!
  3. And update the screen:

    window.update()

    Don’t forget to window.handle_events()!

  4. You can also save the screen:

    window.screenshot("screenshot.png")

That’s all!

Installation

Use pip:

pip install logngraph

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.15.tar.gz (10.9 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.15-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logngraph-0.0.15.tar.gz
  • Upload date:
  • Size: 10.9 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.15.tar.gz
Algorithm Hash digest
SHA256 604dae240c32790b351a406c45361010a6bb0ef03205239076f3b9588670d5a4
MD5 90a0b43b0d57bec21a7205ba1df807c5
BLAKE2b-256 bb4fb6b9b7b7a9d7cf2815b305bc4652a421e8c91d114d5ed052c2804038bd85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logngraph-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.15-py3-none-any.whl
Algorithm Hash digest
SHA256 97bdfe70c9a9a64f4e3f016824c979853de0c56342c8211ef881b9580e355dd9
MD5 81dc647415bf22c4a028ac55b3fd6709
BLAKE2b-256 8d0dc445f1cc40cccf321c65577742bd7a11e1d2961aa7cf6480a68672deddac

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