merging loglevel array to shared

This commit is contained in:
Peter Molnar 2017-07-05 21:09:06 +00:00
parent 68c796f924
commit ba08942632
3 changed files with 24 additions and 15 deletions

View file

@ -1969,15 +1969,8 @@ class NASG(object):
logging.root.removeHandler(logging.root.handlers[-1]) logging.root.removeHandler(logging.root.handlers[-1])
# --- set loglevel # --- set loglevel
llevel = {
'critical': 50,
'error': 40,
'warning': 30,
'info': 20,
'debug': 10
}
logging.basicConfig( logging.basicConfig(
level=llevel[shared.config.get('params', 'loglevel')], level=shared.LLEVEL[shared.config.get('params', 'loglevel')],
format='%(asctime)s - %(levelname)s - %(message)s' format='%(asctime)s - %(levelname)s - %(message)s'
) )

21
pesos.py Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import json import json
import os import os
import hashlib import hashlib
@ -12,8 +14,7 @@ import arrow
import bs4 import bs4
from slugify import slugify from slugify import slugify
import oauth import oauth
import argparse
from pprint import pprint
""" TODO """ TODO
@ -720,11 +721,21 @@ class DAFavs(Favs):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Parameters for NASG')
parser.add_argument(
'--loglevel',
default='error',
help='change loglevel'
)
params = vars(parser.parse_args())
while len(logging.root.handlers) > 0: while len(logging.root.handlers) > 0:
logging.root.removeHandler(logging.root.handlers[-1]) logging.root.removeHandler(logging.root.handlers[-1])
logging.basicConfig( logging.basicConfig(
level=10, level=shared.LLEVEL[params.get('loglevel')],
format='%(asctime)s - %(levelname)s - %(message)s' format='%(asctime)s - %(levelname)s - %(message)s'
) )
@ -742,7 +753,3 @@ if __name__ == '__main__':
da = DAFavs() da = DAFavs()
da.run() da.run()
#flickrfollow = FlickrFollowing()
#flickrfollow.run()

View file

@ -10,6 +10,15 @@ from whoosh import fields
from whoosh import analysis from whoosh import analysis
from slugify import slugify from slugify import slugify
LLEVEL = {
'critical': 50,
'error': 40,
'warning': 30,
'info': 20,
'debug': 10
}
def __expandconfig(config): def __expandconfig(config):
""" add the dirs to the config automatically """ """ add the dirs to the config automatically """
basepath = os.path.expanduser(config.get('common','base')) basepath = os.path.expanduser(config.get('common','base'))