Giter VIP home page Giter VIP logo

woodchips's Introduction

Woodchips

The cutest little logger you've ever seen.

Build Status Coverage Status PyPi Licence

Showcase

Aren't logs just a bunch of woodchips?

Woodchips was created to be the cutest little logger you've ever seen. I wanted something dead simple and reusable as I found myself using the same logging setup over and over in projects. Woodchips gives you everything you need to setup the Python logging library in your project, all without the need to import or call on the logging package, know the various syntaxes for setting up handlers and formatters, etc which makes logging with Woodchips incredibly simple and clean.

Install

# Install tool
pip3 install woodchips

# Install locally
just install

Usage

  • A Logger instance must be created to use Woodchips. Simply specify a name and logging level, tell Woodchips where to log items (console and/or files), and start chipping away!
  • Need multiple loggers, no problem. Spin up separate Logger instances for your needs. Maybe you need a console logger for certain output that requires a specific format while another module needs a generic file formatter. Woodchips makes it easy to setup and configure all your loggers.
  • Logging to a file: Woodchips will automatically roll over your log files once it reaches the log_size. You can configure num_of_logs to specify how many log files will be kept in the rotation.
    • NOTE: Woodchips has a very small default log size of just 200kb with 5 log files for a total of 1mb of logs. For production applications, these values may need to be drastically increased.
  • Formatters: You can configure the format of log files per handler (console and/or files); however, defaults are set (and shown below) if you just need basic logging.

Setting up Woodchips

import woodchips

# Setup a new logger instance
logger = woodchips.Logger(
    name='my_logger_name',  # The name of your logger instance, often will be `__name__`
    level='INFO',  # The log level you want to use
)

# Setup console logging
logger.log_to_console(formatter='%(message)s')

# Setup file logging
logger.log_to_file(
    location='path/to/log_files',
    formatter='%(asctime)s - %(module)s.%(funcName)s - %(levelname)s - %(message)s',
    log_size=200000,  # Size of a single file in bytes
    num_of_logs=5,  # Number of log files to keep in the rotation
)

Using Woodchips

import woodchips

# Retrieve a logger instance by name (assumes it's already been created)
logger = woodchips.get('my_logger_name')

# Log a message (will be logged to console and a file based on the example from above)
logger.info('This is how to setup Woodchips!')

Logger Levels

  • CRITICAL
  • ERROR
  • WARNING
  • INFO
  • DEBUG
  • NOTSET

Development

# Get a comprehensive list of development tools
just --list

woodchips's People

Contributors

justintime50 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nwithan8

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.