Skip to main content

Log library

Project description

SmileLog

SmileLog 2.0 is a big change for backup file. This feature will make log easy to tail with the same name, and backup a yesterday log file.

  • $ tail -f my-log.log
  • Backup file: my-log-2020-05-25.log

It's gonna change the traditional tracing in another way.
What will it assist us:

  1. Colorise output
  2. Be able to stop any output via its public id
  3. Split each output with a big span and symbols
  4. Generate a new dynamic log filename
  5. Disable the entire tracing in a second
  6. 5 methods for 5 outputs
  7. Backup file if log start a new date

To Support my work, please donate me via Buy me a CoffeeBuy me a Pizza

5 Methods

Use in different situation, and show up in different color

  1. track: track(title, content, id= None)
  2. information: info(title, content, id= None)
  3. success: success(title, content, id= None)
  4. warning: warning(title, content, id= None)
  5. error: error(title, content, id= None)
- title is a string
- content can be a string or dict

Start using in the simple way:

from smilelog import Logger


# first instant
log = Logger(
            enable= True
	)

# try to print out
log.info(
	'My Info Title'
	, {'data':'My Dictionary Content'}
	)

# success method
log.success(
	'My Success Title'
        , 'My String'
        )

Logger

Logger is a tracing class library and write/output into a file.
This will need generating a file and keep writing the content. Let's Look at its configure would explain more:

log	= Logger(
            path: str, 
            prefix: str, 
            extension: str, 
            formatFileName: str, 
            enableLog: bool= True,
            enableConsole: bool= True,
            color: bool = True
	)
  • path: is a directory
Ex:
/var/www/my-project/logs/
  • formatFileName: is suffix name of log file
# set filename
formatFileName = 'my-logger'
Ex:
/var/www/my-project/logs/my-logger

# in dynamic way
formatFileName = '%Y-%m-%d'
Ex:
/var/www/my-project/logs/2020-01-19
  • extension: is an extension of log file. The standard extension is '.log'
# set extension
extension = '.log'
Ex:
/var/www/my-project/logs/2020-01-19.log
  • prefix: is prefix name of a new file log.
# set prefix
prefix= 'my-log-'

Ex: 
/var/www/my-project/logs/my-log-2020-01-19.log 
# some app move it into system log directory, it is an advantage of prefix

Ex:
/var/log/my-project-2020-01-19.log
  • color: is for showing the color on terminal with tail command or terminal editor.
# set color
color= True
or
color= False
  • enableLog: allow object to create file.
    • True: To create a file and write content into log file
    • False: To disable the logging
# set enable
# enable to write log file
enableLog= True
  • enableConsole: to bring something on the screen of log.
    • True: To print out on terminal
    • False: No action
# set enable
enableConsole= True

Disable print out

The most feature developer guy needs.
It will disable only the index that we set in the disable list.

Note:

console and log object are not related each other.

# Logger instant
# Ex: Logger logged 10 times
# but we will show some id except 1,2,3,7,8,9
# do this
log.disable([1,2,3,7,8,9])

Output

It's gonna show like this:

02:48:29 <id: 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[SUCCESS] Success 
{'data': 'my content'} 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



02:48:29 <id: 8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[WARNING] Warning 
{'data': 'my content'} 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



02:48:29 <id: 9>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[SUCCESS] Success 
{'data': 'my content'} 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



02:48:29 <id: 10>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[SUCCESS] Success 
Hello String 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

My unique slogan is:

a little developer in the big world \o/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SmileLog-2.0.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

SmileLog-2.0.1-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page