我有一个使用记录器的PyQt4 GUI(写到stdout)
GUI还具有QPlainTextEdit,其中还显示了日志消息
我注意到这里的消息会延迟显示,所以我想知道是否可以在终端上同时显示它们
我想在这篇文章之后使用多重处理(不确定正确的方法)
How should I log while using multiprocessing in Python?
这是我的日志
const passportLocalMongoose = require('passport-local-mongoose'),
mongoose = require('mongoose');
// CREATION USER SCHEMA
const userSchema = new mongoose.Schema({
username: String,
password: String,
email: String,
isAdmin: {type: Boolean, default: false}
});
userSchema.plugin(passportLocalMongoose);
//EXPORT FROM USER SCHEMA
module.exports = mongoose.model('User', userSchema, 'users');
然后我在主代码中使用此代码
class QPlainTextEditLogger(logging.Handler):
"""
class that defines a handler to write logging message inside the GUI
"""
def __init__(self, parent):
super().__init__()
#first creates a text edit widget (parent is the main gui)
self.widget = QtGui.QPlainTextEdit(parent)
#adding this newly created widget to gridLayout_4
parent.gridLayout_4.addWidget(self.widget,4, 0, 1, 2)
self.widget.setReadOnly(True)
def emit(self, record):
msg = self.format(record)
self.widget.appendHtml(msg)
我想知道是否有人可以帮助设置