Giter Site home page Giter Site logo

logandprint's Introduction

Log and Print

PyPI version License Downloads

A simple logging package that helps you to log what is happening in your application.

Installation

You can install Log and Print using pip:

pip install logandprint

Usage

To start logging it is as simple as importing the logandprint object and issuing the logging commands:

write, info, error, success, warning, debug

To logging a message to the log:

import logandprint as log

log.write("This is a common log message")
log.info("This is log information, it appears blue in the terminal")
log.error("This is an error message, it appears red in the terminal")
log.success("This is a success message, it appears green in the terminal")
log.warning("This is a warning message, it appears yellow in the terminal")
log.debug("This is a debug message, it appears white in the terminal")

The write, info, error, success, warning methods accept two parameters, the message and the console flag (boolean) to display or not the message in the terminal.

In the debub method, messages will only be displayed in the terminal if debug mode is active log.debugMode(True)

setLogFile

By default, the log is saved in the log.log file in the current directory. But you can change the log file by using the setLogFile function.

log.setLogFile("./logs/myLogFile.log")

debugMode

The log packet will not be printed to the console. You can change this by setting debugMode to True.

log.debugMode(True)

To stop printing to the console, change the debugMode setting to False. Don't worry, the log file will still be writing.

log.debugMode(False)

enable

To disable the log you can call the enable function and set it to False.

log.enable(False)

And to enable it again you can call the enable function and set it to True.

log.enable(True)

export_to_csv

You can export the log to a csv file by calling the export_to_csv function.

log.export_to_csv("./logs/myLogFile.csv")

Author

  • Guilherme Saldanha

Copyright

This software is free to use and distribute. You can use it for any purpose, but please give credit to the original author.

For more info see LICENSE file.

logandprint's People

Contributors

guisaldanha avatar

Watchers

 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.