Skip to content
forked from ydf0509/nb_log

py-log is a simple logging tool(support log file,email,dingtalk) ,mutil thread and process safe

Notifications You must be signed in to change notification settings

abo123456789/py-log

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 

Repository files navigation

Function description

py-log is a simple logging tool(support file,email,dingtalk, wechat) ,mutil thread and process safe

Version description

  • Supported version: Python 3.0+

Pip installation

pip install py-log

Demo

# log console 
from py_log import get_logger

log = get_logger('test')
log.info('123')
# log write file
from py_log import get_logger

logger = get_logger('test1', log_filename='test1.log')
logger.info('aaaa')
logger.debug('bbbb')
logger.warning('cccc')
logger.error('dddd')
# log send dingding
from py_log import get_logger

ding_talk_token = 'xxxxxxxx'
logger = get_logger('ding_talk_test',ding_talk_token=ding_talk_token, at_mobiles=('13790000000', '13790000001'))
logger.info('钉钉调试')
# log send wechat
from py_log import get_logger
logger = get_logger('weichat_test', agentid='xxx', at_users='aa|bb', corpid='yyy', corpsecret='zzz')
logger.info('企业微信通知')
# log send email
from py_log import LogManager
from py_log.log_manager import MailHandlerConfig

mail_config = MailHandlerConfig()
mail_config.mailhost = ('smtp.sohu.com', 465)
mail_config.fromaddr = 'aaa@sohu.com'
mail_config.toaddrs = 'bbb@qq.com'
mail_config.credentials = ('mail_username', 'mail_password')
logger_mail = LogManager('log_mail_test').get_logger_and_add_handlers(mail_handler_config=mail_config,
                                                                          is_add_mail_handler=True)
logger_mail.info('test send mail content')

About

py-log is a simple logging tool(support log file,email,dingtalk) ,mutil thread and process safe

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%