Skip to content
/ neatlog Public

A simple but fancy looking logger, so You don't have to worry about setting it up.

License

Notifications You must be signed in to change notification settings

fynnay/neatlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neatlog

Very simple but fancy looking logging module. It's based on python's standard logging module and uses the colorlog module written by Sam Clements (@borntyping on GitHub) and colorama by Jonathan Hartley (@tartley on GitHub) to output colored logs to the console on Mac, Linux and Windows.

If you quickly want to create informative and easy to read logs with some flexibility this is the right module. If you want lots for flexibility this is not the right module.

example

Basic usage

import neatlog
LOG = neatlog._Logger('test')
LOG.debug('debug {0}'.format("something"))
LOG.info('info')
LOG.warning('warning')
LOG.error('error')
LOG.critical('critical')
LOG.exception("exception")

Enable file handler

LOG.setFilePath("/Users/local/Desktop/test.log")
LOG.enableFileHandler(True)

Change level

Input levelname as a string or use the standard values defined by the python 'logging' module

LOG.setLevel('debug')
LOG.setLevel('info')
LOG.setLevel('warning')
LOG.setLevel('error')
LOG.setLevel('critical')
LOG.setLevel(20)

Change verbosity

This settings is to change how much info is included in each log. The consolehandler verbosity default is 10. The filehandler always has maximum verbosity so it prints as much info as possible to the logfile. You can however change the verbosity of the console handler

LOG.setVerbosity(0)  # Level, message
LOG.setVerbosity(10) # Level, function, message
LOG.setVerbosity(20) # Level, file, function, message
LOG.setVerbosity(30) # Level, file, function, line, message
LOG.info("something")

Feel free to suggest stuff or point out bugs etc..

-- CHANGELOG The format is based on Keep a Changelog

[1.0.1-beta] - 2017-08-19

Changed

  • Fixes a bug that caused the fileHandler to log the wrong parent function name

Added

  • FileHandler now has same indentation style as consoleHandler for better readability

[1.0.0-beta] - 2017-08-13

Changed

  • Fixed bug messing with stacktrace, which displayed wrong linenumbers, file- and functionnames in log messages

Removed

  • To fix the bug mentioned above, I unfortunately had to remove the functionality to pass a tuple into the log functions. Writing custom functions to for stacktracing correctly got too messy and the payoff isn't big enough. Sorry 'bout that.

About

A simple but fancy looking logger, so You don't have to worry about setting it up.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages