add postfix to logfile

This commit is contained in:
ossean 2016-04-21 12:24:52 +08:00
parent f8809da5b1
commit 8fc187a622
1 changed files with 2 additions and 1 deletions

View File

@ -3,11 +3,12 @@ import urllib2
import logging
import MySQLdb
import time
import sys
r = redis.Redis(host="192.168.80.55",port=6379,db=0)
logger = logging.getLogger()
hdlr = logging.FileHandler("consumer.log")
hdlr = logging.FileHandler("consumer-%s.log"%sys.argv[1])
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)