Problem Statement:
Write a C++/Java program for Log Capturing and Event Correlation.
mainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_3_clicked();
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
******************************************************************
mainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QFile"
#include "QTextStream"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_3_clicked()
{
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
line1.append(line+ "\n");
}
ui->textEdit->setText(line1);
}
void MainWindow::on_pushButton_clicked()
{
ui->textEdit->clear();
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
if(line.count("Updated")!=0)
{
line1.append(line+"\n");
}
}
ui->textEdit->setText(line1);
}
void MainWindow::on_pushButton_2_clicked()
{
ui->textEdit->clear();
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
if(line.count("Installed")!=0)
{
line1.append(line+"\n");
}
}
ui->textEdit->setText(line1);
}
OUTPUT
Write a C++/Java program for Log Capturing and Event Correlation.
PROGRAM
mainWindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_3_clicked();
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
******************************************************************
mainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QFile"
#include "QTextStream"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_3_clicked()
{
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
line1.append(line+ "\n");
}
ui->textEdit->setText(line1);
}
void MainWindow::on_pushButton_clicked()
{
ui->textEdit->clear();
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
if(line.count("Updated")!=0)
{
line1.append(line+"\n");
}
}
ui->textEdit->setText(line1);
}
void MainWindow::on_pushButton_2_clicked()
{
ui->textEdit->clear();
QFile file("/var/log/yum.log");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString line1=" ";
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
if(line.count("Installed")!=0)
{
line1.append(line+"\n");
}
}
ui->textEdit->setText(line1);
}
OUTPUT
No comments:
Post a Comment