GithubHelp home page GithubHelp logo

matthewdeanmartin / bug_trail Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 544 KB

local static html error logger to use while developing python code

License: MIT License

Makefile 3.79% Python 84.09% Jinja 12.11%

bug_trail's Introduction

Bug Trail

This is a workstation logger to capture bugs encountered while you are writing code.

In other words, it is an HTML report writer for your logs, even if they aren't errors if that is your thing.

Installation

The handlers in bug-trail-core support python 3.9+. bug-trail, the report viewer supports python 3.11 and should be installed apart from your main app.

Install bug-trail-core with your app. It has as few dependencies as I could manage.

pip install bug-trail-core

To generate the static website install this in an isolated global virtual environment.

pipx install bug-trail

Usage

Configuration is optional via a pyproject.toml file and the logging modules ordinary configuration options. See example code-as-config

This is the schema with the default values.

[tool.bug-trail]
app_name = "bug_trail"
app_author = "bug_trail"
report_folder = "logs"
database_path = "bug_trail.db"
import bug_trail_core
import logging

section = bug_trail_core.read_config(config_path="../pyproject.toml")
handler = bug_trail_core.BugTrailHandler(
    section.database_path, minimum_level=logging.ERROR
)
logging.basicConfig(handlers=[handler], level=logging.ERROR)

logger = logging.getLogger(__name__)
logger.error("This is an error message")

To generate to the log folder relative to the current working directory:

bug_trail --output logs --db error_log.db

Picologging

If you want to use picologging, install it. Everything is the same except you use the PicoBugTrailHandler.

import bug_trail_core
import logging

section = bug_trail_core.read_config(config_path="../pyproject.toml")
handler = bug_trail_core.PicoBugTrailHandler(
    section.database_path, minimum_level=logging.ERROR
)
logging.basicConfig(handlers=[handler], level=logging.ERROR)

logger = logging.getLogger(__name__)
logger.error("This is an error message")

Do more with your data

pipx install datasette
datasette bug_trail.db

Security

None. Do not publish your error log to the internet or to public Github. Add the log folder to your .gitignore file.

Advanced

Get ctags from here

./ctags -R -f fish_tank.tags fish_tank

Prior Art

Inspired by elmah. bug_trail is much less ambitious, as this is just a browsable, static HTML report.

If you want logger for a website, hosted in your Flak or Django website:

These are the closest "write logs to HTML" projects I could find:

If you want someone else to do it all for you

bug_trail's People

Contributors

matthewdeanmartin avatar

Stargazers

Jeremy Reichman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.