/** * @brief sets the log file that will be used * @param filepath the path to the file that should be used * @return * bool true if file could be opened, false if not */ bool DLDLog::setLogFile (QString filepath) { logFilePath = filepath; if (logFile) { if (logFile->isOpen()) logFile->close(); delete (logFile); } if (filepath.isEmpty()) { setLogType (LOG_TO_CONSOLE); } logFile = new QFile (logFilePath); if (!logFile->open (QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append | QIODevice::Unbuffered)) return (false); setLogType (LOG_TO_FILE); return (true); }
LoggerPlugin::LoggerPlugin(unsigned base, const char *add_info) : Plugin(base) { load_data(loggerData, &data, add_info); string value; CmdParam p = { "-d:", I18N_NOOP("Set debug level"), &value }; Event e(EventArg, &p); if (e.process()) setLogLevel(atol(value.c_str())); if (getLogPackets()) { string packets = getLogPackets(); while (packets.length()) { string v = getToken(packets, ','); setLogType(atol(v.c_str()), true); } } }
NetmonitorPlugin::NetmonitorPlugin(unsigned base, const char *config) : Plugin(base) { load_data(monitorData, &data, config); if (getLogPackets()){ string packets = getLogPackets(); while (packets.length()){ string v = getToken(packets, ','); setLogType(atol(v.c_str()), true); } } monitor = NULL; CmdNetMonitor = registerType(); IconDef icon; icon.name = "network"; icon.xpm = network; icon.isSystem = false; Event eIcon(EventAddIcon, &icon); eIcon.process(); Command cmd; cmd->id = CmdNetMonitor; cmd->text = I18N_NOOP("Network monitor"); cmd->icon = "network"; cmd->bar_id = ToolBarMain; cmd->menu_id = MenuMain; cmd->menu_grp = 0x8000; cmd->flags = COMMAND_DEFAULT; Event eCmd(EventCommandCreate, cmd); eCmd.process(); string value; CmdParam p = { "-m", I18N_NOOP("Show network monitor"), &value }; Event e(EventArg, &p); if (e.process() || getShow()) showMonitor(); }