Skip a lot of logging.

This commit is contained in:
Micke Prag 2010-08-30 08:54:19 +00:00
parent 5a10864ce0
commit 791a6757e5
4 changed files with 17 additions and 22 deletions

View file

@ -25,19 +25,19 @@ Manager::Manager(Socket *s, QObject *parent)
d->running = true;
connect(this, SIGNAL(finished()), this, SIGNAL(done()));
// connect(d->s, SIGNAL(dataArrived(const QByteArray &)), this, SLOT(dataArrived(const QByteArray &)));
TelldusCore::logMessage(" Manager created");
//TelldusCore::logMessage(" Manager created");
this->start();
}
Manager::~Manager(void) {
TelldusCore::logMessage(" Destroying Manager");
//TelldusCore::logMessage(" Destroying Manager");
d->s->disconnect();
TelldusCore::logMessage(" Disconnected, waiting");
//TelldusCore::logMessage(" Disconnected, waiting");
wait();
TelldusCore::logMessage(" Waited, deleting");
//TelldusCore::logMessage(" Waited, deleting");
delete d->s;
delete d;
TelldusCore::logMessage(" Manager destroyed");
//TelldusCore::logMessage(" Manager destroyed");
}
QVariant Manager::parseMessage(const std::string &message) {
@ -190,7 +190,7 @@ void Manager::run() {
}
continue;
}
TelldusCore::logMessage(data);
//TelldusCore::logMessage(data);
QVariant response(this->parseMessage(data));
Message msg;
if (response.type() == QVariant::Int) {

View file

@ -24,12 +24,12 @@ Pipe::Pipe(QObject *parent)
}
Pipe::~Pipe(void) {
TelldusCore::logMessage(QString("Stopping pipe %1").arg(d->name));
//TelldusCore::logMessage(QString("Stopping pipe %1").arg(d->name));
d->closing = true;
if (d->event != INVALID_HANDLE_VALUE) {
SetEvent(d->event);
}
TelldusCore::logMessage("Waiting for thread to close");
//TelldusCore::logMessage("Waiting for thread to close");
this->wait();
delete d;
}
@ -50,18 +50,15 @@ void Pipe::run() {
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == NULL) {
TelldusCore::logMessage("LocalAlloc Error");
return;
}
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
TelldusCore::logMessage("InitializeSecurityDescriptor Error");
LocalFree(pSD);
return;
}
if(!AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID)) {
TelldusCore::logMessage("AllocateAndInitializeSid Error");
LocalFree(pSD);
}
@ -80,7 +77,6 @@ void Pipe::run() {
pACL,
FALSE)) // not a default DACL
{
TelldusCore::logMessage("SetSecurityDescriptorDacl Error");
LocalFree(pSD);
FreeSid(pEveryoneSID);
}
@ -95,7 +91,7 @@ void Pipe::run() {
d->event = oOverlap.hEvent;
while(!d->closing) {
TelldusCore::logMessage(QString("Starting listening in pipe %1").arg(d->name));
//TelldusCore::logMessage(QString("Starting listening in pipe %1").arg(d->name));
HANDLE hPipe = CreateNamedPipe(
(const wchar_t *)d->name.utf16(), // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
@ -122,10 +118,10 @@ void Pipe::run() {
bool connected = GetOverlappedResult(hPipe, &oOverlap, &cbBytesRead, false);
if (d->closing || !connected) {
CloseHandle(hPipe);
TelldusCore::logMessage("Closing or no connection, restart");
//TelldusCore::logMessage("Closing or no connection, restart");
continue;
}
TelldusCore::logMessage("Connected");
//TelldusCore::logMessage("Connected");
emit newConnection(new Socket(hPipe));
}

View file

@ -61,14 +61,14 @@ void TelldusCore::managerDone() {
}
void TelldusCore::newConnection(Socket *socket) {
logMessage(" New normal Connection");
//logMessage(" New normal Connection");
//QLocalSocket *s = d->server.nextPendingConnection();
Manager *m = new Manager(socket, this);
connect(m, SIGNAL(done()), this, SLOT(managerDone()));
}
void TelldusCore::newEventConnection(Socket *socket) {
logMessage(" New eventConnection");
//logMessage(" New eventConnection");
// QLocalSocket *s = d->eventServer.nextPendingConnection();
//connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected())); //TODO: Must check for disconnect somehow
d->eventSockets.append(socket);
@ -121,6 +121,7 @@ void TelldusCore::deviceChangeEventSlot(int deviceId, int eventId, int changeTyp
}
void TelldusCore::rawDeviceEventSlot(const QString &data, int controllerId) {
logMessage(data);
Message msg("TDRawDeviceEvent");
msg.addArgument(data.toStdString());
msg.addArgument(controllerId);
@ -137,7 +138,7 @@ void TelldusCore::logMessage( const QString &message) {
#ifdef _WINDOWS
return;
static bool firstRun = true;
QFile file("C:/log.txt");
QFile file("C:/log_server.txt");
if (firstRun) {
file.open(QIODevice::WriteOnly | QIODevice::Text);
firstRun = false;

View file

@ -135,13 +135,11 @@ void WINAPI TelldusWinService::serviceMain( DWORD argc, TCHAR* argv[] ) {
if (!deviceNotificationHandle) {
TelldusCore::logMessage(QString("Fail RegisterDeviceNotification"));
} else {
TelldusCore::logMessage(QString("Success RegisterDeviceNotification"));
}
TelldusCore::logMessage(QString("Main thread waiting for service to stop"));
//TelldusCore::logMessage(QString("Main thread waiting for service to stop"));
app.exec();
TelldusCore::logMessage(QString("Main thread waited, shutting down"));
//TelldusCore::logMessage(QString("Main thread waited, shutting down"));
// service was stopped
instance.serviceStatus.dwCurrentState = SERVICE_STOP_PENDING;