forked from h080294/appium_python_android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.py
More file actions
38 lines (29 loc) · 1.04 KB
/
Copy pathLog.py
File metadata and controls
38 lines (29 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!usr/bin/python
#-*- coding:utf-8 -*-
import logging
import datetime
import os
import sys
from logging.handlers import RotatingFileHandler
from PublicMethod import *
class Log(object):
logger = None
@classmethod
def create_log_file(cls):
logfile = '%s/%s.log' % (os.path.abspath('./log'),get_format_currenttime())
cls.logger = logging.getLogger(__name__)
cls.logger.setLevel(logging.DEBUG)
# 文件handler
filehandle = RotatingFileHandler(logfile, maxBytes=50*1024*1024, backupCount=5, encoding="UTF-8")
formatter = logging.Formatter('%(asctime)s : %(message)s')
filehandle.setFormatter(formatter)
cls.logger.addHandler(filehandle)
# 屏幕handler
console = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s : %(message)s')
console.setFormatter(formatter)
cls.logger.addHandler(console)
if __name__=='__main__':
Log.create_log_file()
Log.logger.debug('this is a debug msg')
Log.logger.info('this is a info msg')