Python脚本日志系统

 

  Python通过logging模块提供日志功能,关于logging模块的使用网络上已经有很多详细的资料,这里要分享的是怎样在实际工程中使用日志功能。

  假设要开发一个自动化脚本工具,工程结构如下,Common这个package是框架功能的实现,Scripts目录是我们编写的测试用例脚本(请忽略其他不相关的目录)。

  我们对日志功能的需求如下:

  1 为了便于日志的查看,每个脚本对应一个日志文件,日志文件以脚本的名字命名

  2 日志路径以及每个脚本保存的日志容量可以设置,比如设置为5MB,则超过后最老日志被自动覆盖

  3 日志功能要使用方便,减少与框架业务功能的耦合

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVwAAADBCAIAAAAM+59SAAAZ7klEQVR4nO2dX2wbR37H9818McCHANXBL0p7vRK4B/nFgNjmWrVGG7mXXtnCTQUURokiZQXjHnQPFZRDYbY4XXR3vlJ1gR55lQ58SAMilm0qlknFPjlUnDTMxVIUW3Zk0bZkN3Z4SBzTdf6wduz8+jDL3ZndIbkkd8ld8vvBArFWu8OhwvlwZnb2uwoBAHqemZkZ7d9KB+sBAHAJkAIAQMBmKZz92d8Ztq3zr7ReLACgbczMzPx7BUekAC8QbS0l5lbu2lrk3ZU5tcytpcTSlq1lgx5nZmbmXgWnpCDdxPMKsaCiKJFs6zVohLsrc4mlLfbfn1dICG3M3J6Fg601x9alINZwbuWTJqUgfzvOScUBHQLHkUjh1KlTx2UsLCzULc5LUri7Mqd+YGs1DP0o8w69ZUrP08q0RwpVathYT0H2dhztaZheELgeiRRu374tlcLt27frFidr8FaOqSaFbERRCcYK3JGyfZFsNqIoSiTDzgrGCpWzK8cJcI2pZsMwfqqFn6s3d5dKQfZ2HB5+YHzjNeTDhzNnzhiMcObMGSvF2SoF3QiMSNa8M5LVzg4GgwovhWDQcJgA3zhkDUPvBRh+a5TC0fPbQodhayl+9JeZRELv6jMprCype/Sytpa0w/S9wsF8n0Soob6Db3N6gfx7E1/C/HbMbVZSDt1dmavsFGW6tZRImN+mcCL6Cp5CLoX79++fOHFCM8KJEyfu379vp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rFIqVSNDqqrmtgm3Mh0QhuZauVcMUBtIiDUtAolymVolBIfehANOr4V1kPBreWy+rCBIwdQIu0Qwoa7LkDbBscpIkJSqddt1zao4yO4pkOwB7aKgUiWlujkRG1y8CPKaJRTJg3Samkrmju76disdO1Ad6n3VLQ2NigZJLCYXWNg7YNDVE0Suk05XLqhg96DVIp1bB9fbg/GthDx6TAk8tRPC7pQfCb309DQ2qfYnpa9UVvDj3yeaNPQ6Ee/VMAJ3CFFHjW1iiZpGiUwmEaGlK3aqbQtkBAPTIcpmhUEEcu5/lLdKUS5XIUjdLwsHAph3WssJYZ2IvrpFCDYpFyOUqlKBqlkRHVAobRh0V3hEKqO6JRWlx0V7+DKYCZcWjI2Hvy+9XuUjqNgRVwHLdLoTZav0Br7Vpfg2VGWd/6+/VOyuioXuDUlP4q5s1KXPL2tnDK1JRQVX7FF78NDlI4TPE4Zg1Au/G2FCyiNch4XG2QY2Nq+2dP0Oz4xioTjVIqBQuADvP/zmBvOVTVHNoAAAAASUVORK5CYII=" alt="" />

  现在来逐一分析上述需求。

  1 要实现每个脚本一个日志文件,则需要在日志模块中,根据用例脚本的名字来生成日志文件,这里的关键问题就是怎样在日志模块中获取用例脚本的名字。

  获取文件名的常用方法有:os.getcwd(), sys.argv[0], __file__,来看下各种的作用:

  先在一个文件(假设为test.py)中编写如下代码:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS8AAACOCAIAAADvixlwAAAKRElEQVR4nO2dTW/bRhqA5y/1FB73tr0V2B62TVG0biCu29wWyG3RGAV8KkAEe3DOSYti0brbOBsGBYq4SNIYSdrddX2INyYWbWKgRZxFkjqyI+Zr9sCvIYeUZIkyX0rPg0FCjYYSZenBO0Ny3lGPBrG+vq4BYPIobAQQAjYCSAEbAaSAjQBSwEYAKWAjgBTKbVyvJtnxlqtOKrXsN3nwAFNFpY2lrZuIk2gPs4J4G4PLDjbCbDCajVG8WjAkSWvi4vollY63EzePHVtQaskLjJbOkpN7ZfMV+goZ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mkps2mvl7zBTc1Tk78DGGaT+643dm6cfX5zrfj23f+3P+2snul/PPb441715uqxtg5k4tJ13I5Im/2MfnJvDiHulqTRyTczpx9F04/x70VOdaeq38fnjnd++Otr139m79P7e6vGu/85vXx19/vheWdsGM3GU5t0ohLUD5eaoSmxTsXskaDFdQNlZHF87nMWZDSZyZ9yCRUXDBjNx2Hk34tqyvIv9cnPk8lQd6fyx7JJgSf6O0jTGXOGYbSZi4z8sKhpKy8QxoawzQ+bv4Or/rNNgbBSViWOI8eEYkL8DhmEiNp47d+7vBisrK5M4dIApYyI2rq2tLS4uRlFxcXHx2rVrkzh0gClD6afb/cv6+vrANpQxS9SJbfwwKM0WbBRRsJGisVFIwUaKxkYhBRspGhuFFGykaGwUUrCRogfaGF3eQMiJfw3YSOlvo3mlsXkhwyuuOqnUWT+8e6jve/5ochfNUT+8q8MzbrTxdFuHZ1zzqXG+Bmyk9LHRvujfvJBDlhq9Dc+46hVvs+/rmH6O/DVgI6XKxqr7b9oh5OZ5p04bB5mGjZSaSnM2xhEsmw/lfLyRVR45lWTiOOuHd43GiWPF3U85x84HuZYL4wqZdUTNbqrVL7Vt3PzQUUoNDKrm14CNlP42ruepPzamXcoomh3J6eR8vFHeOP3dxzWnvM38UzX3VAe5V6gJr3pHXvE27+rwjHvkw2C4Y8BGim64p5ppY/hT5VKljfndzfrNjSFlqD7CEWy0IuowXwM2UqTYWBIb67Dx/Nk6OqsjxMYDDyOxkaJl2BiP/dzz1aM+u94aduZ2iU/kWN3dgx1e1bjRfpiPhPG4USl6qpSDlEobq6jz7SOjopDY9B+i4a8BGylN3hlX48nPA7/1mWOqwO9+X6z5w0r3Z/10O9y7s/Hjv8K9O6Nt/7j+12HeCxspembvU739n43dB/+V8y82UvTM2jhmxKt9Gxsp+uk2K40DSAEbAaSAjQBSwEYAKWAjgBSwEUAK2AggBWwEkAI2Akjh/5kt/YtESvm5AAAAAElFTkSuQmCC" alt="" />

  然后在另一个文件中(假设为script1.py)中import test,然后调用func方法:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAABDCAIAAACdljksAAAChklEQVR4nO2cy3GsMBBFOyyF4ESsNDwRaOkoZvkUgDOY1SxGGczqZdBvwUc/GAMWfhT3nppygZDAVYfuhgUtfytut5uSMyKUjQNlA0HZQFA2EJQNBGUDQdlAUDYQlA0EZQNB2UAsl3238iFy9b/9H5JmHDCyF95V3opdf+dtW3USjic7fJklsoMzG7RtW3UWFsruou2SOBhH+p/1E4PGPfvpvcKLyKcLyUzzabIzp2d44dtb6UjMBWdERIwL5aRhbGoVEptr9t3Kh9hr8veeTevsmq+gqvp0ph7svcYbYvpCcxQJOTjTKfU2qq2lMo3vITub/3pw5kLhGcpDKYW2GMZJ4HaDMdYp+9ci+2JdHdnzsv31u0xuvap671VVgzOFRe96yangYhUWa2t2XlxnZaeFXFXna/ZkbR4mVxm+wNs0jPuaPUbyuF/U6HwVEs2fxu82xi45Fm1lL3yWJv+H471nk92gbCAoGwjKBoKygaBsICgbCMoGgrKBoGwgKBsIygaCsoGgbCAoGwjKBoKygaBsICgbCMoGgrKBoGwgKBsIygaCsoGgbCAoG4hTyg7u3T00uHfH7wtTjiE7fknf4FPasfVC7MZAVHWN7P26E3kr7ZxE1arUnbNY9o7diRq2vqjk0nbCQtn7dSfKeqH86XetHzbGEWsnr153VSibbSA3USnYnMYbdieqW+F0u+lG3wllGBkzRtFKhbJfsVl2w+5ES2TPbRQwjb9ivez23YlmZMd6XzuOx4L3IT8ZH9DmWPXq9fPuRJNptswQw8OAMSIib2/x6FjR47rKZXoX5ubhOcZ7dmO8Ne4xkXvQOaVsMg1lA0HZQFA2EJQNBGUDQdlAUDYQ/wBIi+mWU1amkQAAAABJRU5ErkJggg==" alt="" />

  运行script1.py,结果为:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZsAAABXCAIAAABdp3/UAAAKVElEQVR4nO2czZ3jLAyH3dW6hO1gKxjKmOmA25z27SDX4Z4qclg3ML804ffg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okoYodwZi1KrK7TAtfzF1cq6q3LJdfrM1qnKbcCw+/lm+rV2Vm9jO9sqfQ7dXLM6N33MAcNninYHoKjxxxeQtd9faY716dKtvuxBpnna1gG1AVe4fSPKnxt2RgkqsFpAA73UCANoBHg0A0A7waACAdoBHAwC0AzwaAKAd4NEAAO0AjwYAaAd4NABAO8CjAQDaAR4NANAO8GgAgHaARwMAtAM8GgCgHeDRAADt8D8YlWDC9dbp/AAAAABJRU5ErkJggg==" alt="" />

  可见,os.getcwd()获取的是执行脚本的目录, sys.argv[0]是执行脚本的绝对路径名, __file__是被执行代码所在文件的绝对路径名。

  现在就清楚了,我们应该用sys.argv[0]来获取执行脚本的名字,由于获取到的是绝对路径,需要做一点处理:sys.argv[0].split('/')[-1].split('.')[0]

  2 日志容量问题,要实现超过容量后自动覆盖最老日志,采用logging中的RotatingFileHandler类即可,可以设置日志文件的大小,以及备份个数。

  那么日志路径和容量配置放在哪里呢?让用户直接修改RotatingFileHandler的参数显然不好,最好不要让用户修改框架文件,用户只需调用接口写自己的脚本即可。

  这里采用的方案是将配置信息写入一个文件,XML文件比较适合用来作为配置文件,用户通过修改XML文件来制定配置,日志模块从XML文件读取参数。

  这里为了方便将XML文件放入Common下面,命名为config.xml,内容为:

<?xml version="1.0" encoding="utf-8"?>

<config>
<!-- 日志保存路径 -->
<logpath>E:\PythonLog</logpath> <!-- 每个脚本对应的日志文件大小,单位MB -->
<logsize>8</logsize> <!-- 每个脚本保存的日志文件个数 -->
<lognum>3</lognum>
</config>

  读取XML文件内容,使用lxml库非常简单,后面再给出代码。

  

  3 日志功能要使用方便,减少与框架业务功能的耦合,最好就是对日志功能进行封装,只提供记录日志的接口即可。

  日志接口采用类方法的形式就可以满足上述要求,用户只需要通过类调用日志记录接口,随处调用,使用方便,并且无需定义类实例,与框架业务没有耦合。

    

  有了上述分析,我们来实现日志模块。

  由于日志功能也是框架基础的一部分,我们将日志模块也放在Common这个package中,在Common下新建log.py文件,代码如下:

 1 # coding: utf-8
2
3 from lxml import etree 或者from lxml import html
4 import logging.handlers
5 import logging
6 import os
7 import sys
8
9 # 提供日志功能
10 class logger:
11 # 先读取XML文件中的配置数据
12 # 由于config.xml放置在与当前文件相同的目录下,因此通过 __file__ 来获取XML文件的目录,然后再拼接成绝对路径
13 # 这里利用了lxml库来解析XML
14 root = etree.parse(os.path.join(os.path.dirname(__file__), 'config.xml')).getroot()
15 # 读取日志文件保存路径
16 logpath = root.find('logpath').text
17 # 读取日志文件容量,转换为字节
18 logsize = 1024*1024*int(root.find('logsize').text)
19 # 读取日志文件保存个数
20 lognum = int(root.find('lognum').text)
21
22 # 日志文件名:由用例脚本的名称,结合日志保存路径,得到日志文件的绝对路径
23 logname = os.path.join(logpath, sys.argv[0].split('/')[-1].split('.')[0])
24
25 # 初始化logger
26 log = logging.getLogger()
27 # 日志格式,可以根据需要设置
28 fmt = logging.Formatter('[%(asctime)s][%(filename)s][line:%(lineno)d][%(levelname)s] %(message)s', '%Y-%m-%d %H:%M:%S')
29
30 # 日志输出到文件,这里用到了上面获取的日志名称,大小,保存个数
31 handle1 = logging.handlers.RotatingFileHandler(logname, maxBytes=logsize, backupCount=lognum)
32 handle1.setFormatter(fmt)
33 # 同时输出到屏幕,便于实施观察
34 handle2 = logging.StreamHandler(stream=sys.stdout)
35 handle2.setFormatter(fmt)
36 log.addHandler(handle1)
37 log.addHandler(handle2)
38
39 # 设置日志基本,这里设置为INFO,表示只有INFO级别及以上的会打印
40 log.setLevel(logging.INFO)
41
42 # 日志接口,用户只需调用这里的接口即可,这里只定位了INFO, WARNING, ERROR三个级别的日志,可根据需要定义更多接口
43 @classmethod
44 def info(cls, msg):
45 cls.log.info(msg)
46 return
47
48 @classmethod
49 def warning(cls, msg):
50 cls.log.warning(msg)
51 return
52
53 @classmethod
54 def error(cls, msg):
55 cls.log.error(msg)
56 return

  来测试一下,在脚本script1和script2中分别编写下面代码:

from Common.log import *

logger.info('This is info')
logger.warning('This is warning')
logger.error('This is error')

  分别运行两个脚本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3YpsZOc2vO18F5Rc7min/hvCL98n06r8ge7y9Fckr1kS4f77JBx30cfQgpUs31dP6Qtd4hRRpnR9XBEOfz5qdE0DuZVSguZnFekeotzisq43FeUWlTP9DBiG/gJ7uBSeOpfSne5bUFdz8lxnv+kK3e3aVI7i82OzuMtCoqHhRt71mRsVClNYjzikqEZQzOKxL9Ty7zeUVNn+Ex+0bGgULVvcJEjNfKyHyZm0tv8ZP13Cw0uZx37/wh/hL+nCE5XuovcvrdBucVgW7wXT10exdKTRKcV2SNH4pd8wf0DM4rAu3BeUW7yVjyhfOHAD78AwAAYGggRQAAAAYGUgQAAGBgIEUAAAAGBlIEAABgYCBFAAAABsYuRefzafNPLUCKAAAAuGCTorOj6fzs7AhSBAAAYJuIUpR/kPsCUgQAAGC7/B84/8ulBkhYeQAAAABJRU5ErkJggg==" alt="" />

  好了,现在不管是在框架的其他文件中,或是在用户脚本中,都可以方便的通过logger类的日志接口记录日志。

原文链接:http://www.cnblogs.com/haigege/p/5768485.html

使用python实现日志功能的更多相关文章

  1. Python的日志功能

    python自带的logging是日志处理模块,可以记录日志,并输出到控制台和文件等.日志分5个级别:DEBUG:调试信息,权重10INFO:一般信息,权重20WARNING:警告信息,权重30ERR ...

  2. Atitit php java python nodejs错误日志功能的比较

    Atitit php  java  python  nodejs错误日志功能的比较 1.1. Php方案 自带 1 1.2. Java解决方案 SLF4J 1 1.3. Python解决方案 自带lo ...

  3. 【Python】自己写日志功能

    Python有自带的logging模块,用于日志记录,功能很强大,但不好用,使用挺麻烦的,而且发现了几个bug,调用了一个logger.warning()一次,结果日志文件中出现了n行记录,且逐渐变成 ...

  4. Python日志功能与处理逻辑

    前言 在应用程序执行过程中,我们希望通过规范格式输出程序执行的详细信息,这时我们需要用到日志功能.在Python语言中,有个內建模块logging能够很好的实现日志功能.整体来说,logging配置可 ...

  5. python接口测试之日志功能

    之前在简书中看了一篇关于日志功能的文档,供大家参考:https://www.jianshu.com/p/62f7b49b41e7 Python通过logging模块提供日志功能,所以直接导入即可 im ...

  6. Python之日志处理(logging模块)

    本节内容 日志相关概念 logging模块简介 使用logging提供的模块级别的函数记录日志 logging模块日志流处理流程 使用logging四大组件记录日志 配置logging的几种方式 向日 ...

  7. Python脚本日志系统

    Python通过logging模块提供日志功能,关于logging模块的使用网络上已经有很多详细的资料,这里要分享的是怎样在实际工程中使用日志功能. 假设要开发一个自动化脚本工具,工程结构如下,Com ...

  8. 【转】Python之日志处理(logging模块)

    [转]Python之日志处理(logging模块) 本节内容 日志相关概念 logging模块简介 使用logging提供的模块级别的函数记录日志 logging模块日志流处理流程 使用logging ...

  9. Python 配置日志的几种方式

    Python配置日志的几种方式 作为开发者,我们可以通过以下3种方式来配置logging: (1)使用Python代码显式的创建loggers,handlers和formatters并分别调用它们的配 ...

随机推荐

  1. HTML 选择目录

    <input type="file" webkitdirectory directory multiple/>

  2. WebKit最新特性srcset简介(转)

    WebKit内核最新新增了对srcset属性的支持(参考:https://www.webkit.org/blog/2910/improved-support-for-high-resolution-d ...

  3. 不可思议的颜色混合模式 mix-blend-mode (转)

    开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...

  4. 怎样将M4A音频格式转换成MP3格式

    因为MP3音频格式应用的广泛性,所以很多时候我们都需要将不同的音频格式转换成MP3格式的,那么如果我们需要将M4A音频格式转换成MP3格式,我们应该怎样进行实现呢?下面我们就一起来看一下吧. 操作步骤 ...

  5. js常用校验

    //验证金钱数字obj.regexMoney = function (money) { var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)| ...

  6. 洛谷 P1059明明的随机数 & P1068分数线划定 & P1781宇宙总统

    题目:https://www.luogu.org/problemnew/show/P1059 思路:STL中的set使用. //#include<bits/stdc++.h> #inclu ...

  7. LightOJ 1224 - DNA Prefix - [字典树上DFS]

    题目链接:https://cn.vjudge.net/problem/LightOJ-1224 Given a set of $n$ DNA samples, where each sample is ...

  8. 【每日一题】Flooded! UVA - 815 模拟阅读格式题

    https://cn.vjudge.net/problem/UVA-815 题意:给你一个矩阵,每个格子的数代表一个海拔并且每个格子的面积100平方米.给你整个区域的降水量(立方米),问降水量(米). ...

  9. Vue SSR 配合Java的Javascript引擎j2v8实现服务端渲染2创建Vue2+webpack4项目

    前提 安装好nodejs并配置好环境变量,最好是 node10,https://nodejs.org/en/download/ 参考我之前的文章 debian安装nodejs Yarn &&a ...

  10. 使用Sqlserver事务发布实现数据同步(sql2008)_Mssq l数据库教程

    事务的功能在sqlserver中由来已久,因为最近在做一个数据同步方案,所以有机会再次研究一下它以及快照等,发现还是有很多不错的功能和改进的.这里以sqlserver2008的事务发布功能为例,对发布 ...