Code Monkey home page Code Monkey logo

kwikpic_logger's Introduction

Logger

  • Logging

Logging is a means of tracking events that happen when some software runs. The software’s developer adds logging calls to their code to indicate that certain events have occurred.

This logger is defined to serve the primary logging
Logs are being saved as UCODE.log in current directory

Requiremts
pip install requirements.txt

Importing Logger

from logger import Logger

Fetching or declaring

Valid thresholds

Acceptable threshold When it's used
DEBUG Detailed information, typically of interest only when diagnosing problems.
INFO Confirmation that things are working as expected.
WARNING An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.
ERROR Due to a more serious problem, the software has not been able to perform some function.
CRITICAL A serious error, indicating that the program itself may be unable to continue running.
UCODE     = 'C-192'
threshold = 'debug'   # Not case-sensitive 
logs = Logger(UCODE,threshold)
  • Using Logger
logs.info('info log message')
logs.debug('debug log message')
logs.warning('error logs ')
logs.error('error log message')
logs.critical('critical log message')

Example 1

from logger import Logger
logs=Logger('my_logs','Debug')

# Loggings 
logs.info('info log message')
logs.debug('debug log message')
logs.warning('error logs ')
logs.error('error log message')
logs.critical('critical log message')

Output:

Logs are saved in file my_logs.log

Output

Example 2

from logger import Logger
logs=Logger('C192','warning')
try:
    print(1/0)
except ZeroDivisionError as zero:
    logs.warning("Can not divide by zero")

Logs are saved in file C192.log

WARNING : 2021-01-28 16:30:43,552 : C192 - Can not divide by zero

kwikpic_logger's People

Contributors

vaibhaw0066 avatar

Watchers

James Cloos 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.