GithubHelp home page GithubHelp logo

pylog's Introduction

PyLog

My Custom Debugger

Basic Use:

from PyLog import Logger, Log, Warn, Error
#Default logger level is 5.
# Logger.level = 8

Log("Hello World") #will log at level 0 (will always show)
Log("Hello World", level=3) #Will log at the level 3
Error("Hello World") #Will log at the Error level
Warn("Hello World") #will log at the warning level
[18 Aug 2019] [07:05:55 PM] [0] [<stdin>.<module>:4] >> Hello World

Setting the debug level and custom format:

from PyLog import Log, Logger

Logger.level = 4 #Anything over level 4 wont be shown in stdout
Logger.error_level = 3 #sets anything between level 3 and the loggers level to be classed as an error.

#The warning level (orange) is (error level + 1) / 2) rounded.

Logger.format = "[(level)] [(date)] [(time)] [(file).(function):(line)] >> (data)" 
#[1] [18 Aug 2019] [06:56:14 PM] [debugger.py.Log:95] >> {'a': 1, 'b': 2, 'c': 3}

Logger.time = "%I:%M:%S %p" #sets the time format
Logger.date = "%d %b %Y" #sets the date format

The formula for the format are a combination of any characters and (<var>) where <var> is one of the following:

  • date
  • time
  • level
  • file
  • function
  • line
  • data

The time and date formats follow the datetime modules format: https://docs.python.org/3.7/library/datetime.html#strftime-and-strptime-behavior

pylog's People

Contributors

kgz avatar

Watchers

James Cloos avatar  avatar

pylog's Issues

Filename error

Warn and Error dont show the correct file.
Can be reproduces in the test.py file.
image

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.