Python实现日志记录功能--样例
来源:互联网 发布:美国女键盘手走红网络 编辑:程序博客网 时间:2024/06/05 06:55
author:skate
time:2014/10/13
Python实现日志记录功能
[root@skatedb55 ~]# vi op_log_file.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#Author:Skate
import os,time
def op_log(log):
f=file(log_file,'a')
date=time.strftime('%Y-%m-%d %H:%M:%S')
record = '%s %s\n' %(date,log)
f.write(record)
if __name__ == '__main__':
log_file='/tmp/log_file.log'
op_log('insert new reacord1')
op_log('insert new record2')
~
运行结果:
[root@skatedb55 ~]# more /tmp/log_file.log
2014-10-13 16:46:51 insert new reacord1
2014-10-13 16:46:51 insert new record2
2014-10-13 16:46:55 insert new reacord1
2014-10-13 16:46:55 insert new record2
---end---
0 0
- Python实现日志记录功能--样例
- python 实现记录功能
- PHP 日志记录功能实现
- 通过注解实现记录日志的功能
- Ibatisnet日志记录功能
- Ibatisnet日志记录功能
- MVC日志记录功能
- java记录日志功能
- yii日志记录功能
- 记录日志功能对比
- Spring 自定义注解实现操作日志记录功能
- spring aop 实现用户操作日志记录功能
- python 日志记录
- python IDE && 日志记录
- python logging 日志记录
- python log 日志记录
- Python如何记录日志
- python 日志记录
- Cocos2d-x 3.3Bate0 ExpandedListView
- C语言基础课程 第四课 它山之石可以攻玉---C语言数据类型和表达式
- linux 磁盘格式,磁盘挂载,及格式化
- ORACLE用SYS登录报ORA-28009:connection as SYS should be as SYSDBA OR SYSOPER解决方法
- HTTPS 能否避免流量劫持?
- Python实现日志记录功能--样例
- HDU 3579 Hello Kiki 中国剩余定理 不互质情况
- SecureCRT 使用技巧
- hadoop-hive-hive多个实例
- STL之双端队列
- 关于readonly的理解——学习笔记
- oracle connect by 官方文档翻译
- 4.4.2.1 创建随机颜色的画笔
- 软件测试流程