Simple Python logging lib
Project description
easylogging2
Simple and Easy Logging lib for python V2
REQUIREMENTS
- Python-3 --> http://www.python.org/download/
Notes
- After 9 months this library has returned better and more useful.
- This library is very simple so it is not better than a logging library and it is derived from it.
- This library was created because I wanted a simple and easy logging library.
Installation
-
Clone this repo:
$ git clone https://github.com/AI35/easylogging2
-
Using pip:
$ pip install easylogging2
Usage
-
First you need import lib and Set name :
import easylogging2 log = easylogging2.logname(__file__)
-
Use the functions you need:
- log.critical(msg)
- log.error(msg, exc_info) default: exc_info=False
- log.warning(msg)
- log.info(msg)
- log.debug(msg)
-
You can start logging from Cmd or PowerShell :
$ Python yourfile.py --logging --logfile usage: youefile.py [--logging] [--logfile] optional arguments: --logging Display log in Console --logfile Create log file
-
After first run you will see new file logging.conf :
- Change level number to display log in console without --logging (0 display all level).
level=50
- Change file_level number to set level in log file with --logfile (50 hide all level).
- This option work on --logfile without use --logging (if you use --logging ,The file will write all levels)
file_level=0
- Change level number to display log in console without --logging (0 display all level).
-
Show and hide error info from logging.conf :
- Show Error info (easylogging.error(msg, exc_info))
- True or False or None
- * (None) means that exc_info takes the value entered from the user, example: easylogging.error(msg, exc_info=True)
exc_info=None
-
You can run the test.py file to see how it works.
-
You can use all logging functions from this lib (ex: easylogging.logging.function)
-
formatter :
- You can use all defaults logging formats.
formatter = %(asctime)s - %(name)s - %(levelname)s - %(message)s
- From logging formatter function :
Formatter instances are used to convert a LogRecord to text. Formatters need to know how a LogRecord is constructed. They are responsible for converting a LogRecord to (usually) a string which can be interpreted by either a human or an external system. The base Formatter allows a formatting string to be specified. If none is supplied, the the style-dependent default value, "%(message)s", "{message}", or "${message}", is used. The Formatter can be initialized with a format string which makes use of knowledge of the LogRecord attributes - e.g. the default value mentioned above makes use of the fact that the user's message and arguments are pre- formatted into a LogRecord's message attribute. Currently, the useful attributes in a LogRecord are described by: %(name)s Name of the logger (logging channel) %(levelno)s Numeric logging level for the message (DEBUG, INFO, WARNING, ERROR, CRITICAL) %(levelname)s Text logging level for the message ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL") %(pathname)s Full pathname of the source file where the logging call was issued (if available) %(filename)s Filename portion of pathname %(module)s Module (name portion of filename) %(lineno)d Source line number where the logging call was issued (if available) %(funcName)s Function name %(created)f Time when the LogRecord was created (time.time() return value) %(asctime)s Textual time when the LogRecord was created %(msecs)d Millisecond portion of the creation time %(relativeCreated)d Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded (typically at application startup time) %(thread)d Thread ID (if available) %(threadName)s Thread name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted
Changlog
V 2.0.5 Some fixes:
- Make some variables private.
V 2.0.1 Performance:
- Increase performance.
-
Level table :
Level Numeric value CRITICAL < 50 ERROR < 40 WARNING < 30 INFO < 20 DEBUG < 10 NOTSET 0
LICENSE
Copyright 2019 LinePY - ALI B OTHMAN(AI35), Inc.
easylogging2
Licensed under the GNU License , you may not use this
file except in compliance with the License.
You may obtain a copy of the License at :
https://github.com/AI35/easylogging2/blob/master/LICENSE
ALI .B .OTH - ORG : LinePY
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
easylogging2-2.0.5.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file easylogging2-2.0.5.tar.gz
.
File metadata
- Download URL: easylogging2-2.0.5.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d27a4a3b2d356f9e63a7f7ce9d7031c75cd66fb46f6b4310244d9fad632bfbae |
|
MD5 | 17c21b1332c6acb4ad4bbea95616136b |
|
BLAKE2b-256 | 4ed532069df2ae01e0786fb98de2fe4d34ffa85c98b7326952e5c73eb108c0a7 |
File details
Details for the file easylogging2-2.0.5-py3-none-any.whl
.
File metadata
- Download URL: easylogging2-2.0.5-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b06e3956bb9ee4a84f671c1f7a87363afe70df9c3d75676643f5a4b6ffe7d2f2 |
|
MD5 | 53d386a6e2fd249dc580c26772e54ed6 |
|
BLAKE2b-256 | a0fc8d77c16367d28b104d8036048428e97aeeabd8442aceaeef1cc56bf637a6 |