Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Log bug #67 #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions rhsda.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@


# Logging
logging.addLevelName(25, 'NOTICE')
consolehandler = logging.StreamHandler()
consolehandler.setLevel('DEBUG')
consolehandler.setFormatter(logging.Formatter("[%(levelname)-7s] %(name)s: %(message)s"))
logger = logging.getLogger('rhsda')
logger.setLevel('NOTICE')
logger.addHandler(consolehandler)
logger = logging.getLogger(__name__)


# Establish cveFields namespace
Expand Down Expand Up @@ -176,7 +170,6 @@ class ApiClient:
def __init__(self, logLevel='notice'):
self.cfg = Namespace()
self.cfg.apiUrl = 'https://access.redhat.com/labs/securitydataapi'
logger.setLevel(logLevel.upper())

def _get_terminal_width(self):
h, w, hp, wp = struct.unpack('HHHH', fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('HHHH', 0, 0, 0, 0)))
Expand Down Expand Up @@ -632,7 +625,7 @@ def _set_cve_plaintext_fields(self, desiredFields):
for f in fields:
# Skip unknown fields
if f not in cveFields.all_plus_aliases:
logger.warning("Field '{0}' is not a known field; valid fields:\n{2}".format(f, ", ".join(cveFields.all_plus_aliases)))
logger.warning("Field '{0}' is not a known field; valid fields:\n{1}".format(f, ", ".join(cveFields.all_plus_aliases)))
continue
# Look-up aliases
if f not in cveFields.all:
Expand Down
16 changes: 11 additions & 5 deletions rhsecapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@
vers = {}
vers['version'] = '1.0.1'
vers['date'] = '2017/06/27'
logLevels = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
'NOTICE': 25,
'ERROR': logging.ERROR,
}



# Logging
logging.addLevelName(25, 'NOTICE')
logging.addLevelName(logLevels['NOTICE'], 'NOTICE')
consolehandler = logging.StreamHandler()
consolehandler.setLevel('DEBUG')
consolehandler.setFormatter(logging.Formatter("[%(levelname)-7s] %(name)s: %(message)s"))
logger = logging.getLogger('rhsecapi')
logger.setLevel('NOTICE')
logger = logging.getLogger()
logger.addHandler(consolehandler)


Expand Down Expand Up @@ -340,7 +346,7 @@ def parse_args():
o.outFormat = 'jsonpretty'
else:
o.outFormat = 'plaintext'
logger.setLevel(o.loglevel.upper())
logger.setLevel(logLevels[o.loglevel.upper()])
return o


Expand Down