mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-09 06:18:05 +00:00
py-i2phosts-maint: get logger with our get_logger()
This commit is contained in:
parent
2a16ddb3d3
commit
f525698af3
@ -13,6 +13,7 @@ DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
|
|||||||
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
||||||
from web.postkey.models import i2phost
|
from web.postkey.models import i2phost
|
||||||
|
from web.lib.utils import get_logger
|
||||||
import configobj
|
import configobj
|
||||||
|
|
||||||
# parse command line options
|
# parse command line options
|
||||||
@ -25,12 +26,6 @@ parser.add_argument('-c', '--config', default='/etc/py-i2phosts/maintainer.conf'
|
|||||||
help='config file to use')
|
help='config file to use')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# configure logger
|
|
||||||
log = logging.getLogger(sys.argv[0])
|
|
||||||
handler = logging.StreamHandler()
|
|
||||||
log.addHandler(handler)
|
|
||||||
if args.debug:
|
|
||||||
log.setLevel(logging.DEBUG)
|
|
||||||
# read config
|
# read config
|
||||||
config = configobj.ConfigObj(args.config_file)
|
config = configobj.ConfigObj(args.config_file)
|
||||||
if 'include' in config:
|
if 'include' in config:
|
||||||
@ -38,8 +33,15 @@ if 'include' in config:
|
|||||||
config.merge(config_included)
|
config.merge(config_included)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
|
# configure logger
|
||||||
|
if args.debug == True:
|
||||||
|
log_level = 'debug'
|
||||||
|
log_file = None
|
||||||
|
else:
|
||||||
|
log_level = config['log_level']
|
||||||
|
log_file = config['log_file']
|
||||||
|
log = get_logger(filename=log_file, log_level=log_level)
|
||||||
|
|
||||||
all_hosts = i2phost.objects.all()
|
all_hosts = i2phost.objects.all()
|
||||||
for host in all_hosts:
|
for host in all_hosts:
|
||||||
|
Loading…
Reference in New Issue
Block a user