mirror of
https://github.com/SELinuxProject/setools
synced 2025-02-19 05:27:03 +00:00
apol: log INFO messages to the status bar
Still keep the CLI messaging controlled by -v or --debug switches. For some reason, the root logging had to be DEBUG for this to work, and only as initialized by basicConfig. Setting a NullHandler to DEBUG level didn't work either.
This commit is contained in:
parent
7d88a1424e
commit
6a4cbf20d5
17
apol
17
apol
@ -35,13 +35,22 @@ parser.add_argument("--debug", action="store_true", dest="debug", help="Enable d
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG, filename="/dev/null")
|
||||
|
||||
console_handler = logging.StreamHandler()
|
||||
|
||||
if args.debug:
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s|%(levelname)s|%(name)s|%(message)s')
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
console_handler.setFormatter(
|
||||
logging.Formatter('%(asctime)s|%(levelname)s|%(name)s|%(message)s'))
|
||||
elif args.verbose:
|
||||
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
||||
console_handler.setLevel(logging.INFO)
|
||||
console_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
else:
|
||||
logging.basicConfig(level=logging.WARNING, format='%(message)s')
|
||||
console_handler.setLevel(logging.WARNING)
|
||||
console_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
|
||||
logging.getLogger().addHandler(console_handler)
|
||||
|
||||
try:
|
||||
app = QApplication(sys.argv)
|
||||
|
@ -25,6 +25,7 @@ from PyQt5.QtWidgets import QAction, QApplication, QDialog, QFileDialog, QLineEd
|
||||
from setools import PermissionMap, SELinuxPolicy
|
||||
|
||||
from ..widget import SEToolsWidget
|
||||
from ..logtosignal import LogToSignalHandler
|
||||
# Analysis tabs:
|
||||
from .dta import DomainTransitionAnalysisTab
|
||||
from .infoflow import InfoFlowAnalysisTab
|
||||
@ -75,6 +76,13 @@ class ApolMainWindow(SEToolsWidget, QMainWindow):
|
||||
tabBar.addAction(self.close_tab_action)
|
||||
tabBar.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||
|
||||
# capture INFO and higher Python messages from setools lib for status bar
|
||||
handler = LogToSignalHandler()
|
||||
handler.setLevel(logging.INFO)
|
||||
handler.setFormatter(logging.Formatter('%(message)s'))
|
||||
handler.message.connect(self.statusbar.showMessage)
|
||||
logging.getLogger("setools").addHandler(handler)
|
||||
|
||||
# connect signals
|
||||
self.open_policy.triggered.connect(self.select_policy)
|
||||
self.open_permmap.triggered.connect(self.select_permmap)
|
||||
|
Loading…
Reference in New Issue
Block a user