Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CD

on:
push:
tags:
- "v*"
workflow_dispatch:

permissions:
contents: write

jobs:
build-linux:
name: Build Linux GUI + CLI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Qt6
run: |
sudo apt update
sudo apt install -y qt6-base-dev qt6-base-dev-tools qt6-tools-dev build-essential cmake libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxext-dev libxrandr-dev libxi-dev libxfixes-dev

- name: Configure CMake
run: cmake -S . -B build -DBUILD_GUI=ON -DCMAKE_BUILD_TYPE=Release

- name: Build GUI
run: cmake --build build --target log-analyzer-gui --config Release

- name: Build CLI
run: cmake --build build --target log-analyzer-cli --config Release

- name: Package Linux artifacts
run: |
mkdir -p artifacts/linux
find build -type f \( -name "log-analyzer-gui" -o -name "log-analyzer-cli" \) -exec cp {} artifacts/linux/ \;
tar czvf artifacts/log-analyzer-linux.tar.gz -C artifacts/linux .

- name: Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/log-analyzer-linux.tar.gz
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-mac:
name: Build macOS CLI
runs-on: macos-latest
needs: build-linux
steps:
- uses: actions/checkout@v4

- name: Install Qt
run: brew update && brew install qt

- name: Configure CMake
run: cmake -S . -B build -DBUILD_GUI=OFF -DCMAKE_BUILD_TYPE=Release

- name: Build CLI
run: cmake --build build --target log-analyzer-cli --config Release

- name: Package macOS artifacts
run: |
mkdir -p artifacts/mac
find build -type f -name "log-analyzer-cli" -exec cp {} artifacts/mac/ \;
zip -r artifacts/log-analyzer-mac.zip artifacts/mac

- name: Upload macOS Asset
uses: softprops/action-gh-release@v2
with:
files: artifacts/log-analyzer-mac.zip
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
branches: [ main ]

jobs:
Tests:
Expand All @@ -25,7 +25,7 @@ jobs:
sudo apt-get update && sudo apt-get install -y cmake build-essential libgtest-dev
fi

cmake -B build
cmake -B build -DBUILD_GUI=OFF
cmake --build build
cd build/tests
./test-runner
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ build/


!tests/test_data/*.log

.DS_Store
.qtcreator/
CMakeLists.txt.user
32 changes: 17 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
cmake_minimum_required(VERSION 3.10)
project(LogAnalyzer VERSION 0.1.0)
project(LogAnalyzer VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
cmake_policy(SET CMP0079 NEW)


find_package(GTest QUIET)
if(NOT GTest_FOUND)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)

FetchContent_MakeAvailable(googletest)
endif()


option(BUILD_GUI "Build GUI version" ON)


add_subdirectory(core)
add_subdirectory(cli)

if(BUILD_GUI)
add_subdirectory(gui)
endif()

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)

add_subdirectory(tests)
49 changes: 19 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Log Analyzer v0.2.1
# Log Analyzer v1.0.0

## 💻 Платформы
- ✅ macOS (clang/gcc, CMake ≥ 3.10)
- Linux (gcc, CMake ≥ 3.10)
- MacOS (cli)
- Linux (cli, gui)

## 🚀 Возможности
### 📋 Поддерживаемые форматы логов:
Expand All @@ -21,39 +21,28 @@
- Язык: C++17
- Сборка: CMake
- Тестирование: Google Test (gtest/gmock)
- CI: Сборка и тестирование
- CI/CD: тестирование и сборка
- Qt: графическое приложение

## 🛠️ В разработке:
- GUI
- Поддержка Windows

## 📦 Установка и сборка
- Клонирование репозитория
## 📦 Установка и запуск
### Linux
Для cli
```
git clone https://github.com/Arkilleru/log-analyzer.git
cd log-analyzer
chmod +x log-analyzer-cli
./log-analyzer-cli
```

- Сборка
```
./run.sh build
```

- Консольное приложение
Для gui
```
./run.sh cli
sudo apt install qt6-base-dev
chmod +x log-analyzer-gui
./log-analyzer-gui
```

- Тестирование
### MacOS
Для cli
```
./run.sh test
chmod +x log-analyzer-cli
./log-analyzer-cli
```

- Очистка
```
./run.sh clean
```

- Очистка + Сборка + Тестирование
```
./run.sh all
```
2 changes: 1 addition & 1 deletion cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_executable(log-analyzer-cli main.cpp)
add_executable(log-analyzer-cli main.cpp reporter.cpp)
target_link_libraries(log-analyzer-cli core_lib)

set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY EP_PREFIX ${CMAKE_BINARY_DIR})
5 changes: 4 additions & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "../core/analyzer.h"
#include "reporter.h"
#include <iostream>

int main() {
Expand All @@ -7,7 +8,9 @@ int main() {
std::getline(std::cin, path);

Analyzer analysis;
std::string report = analysis.analyze(path);
AnalysisResult result = analysis.analyze(path);
Reporter reporter;
std::string report = reporter.GenerateTextReport(result);

std::cout << report;

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion core/reporter.h → cli/reporter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "common.h"

#include "../core/common.h"

#include <vector>

Expand Down
3 changes: 1 addition & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ add_library(core_lib
reader.cpp
parser.cpp
statistics.cpp
reporter.cpp
analyzer.cpp
)
)
7 changes: 3 additions & 4 deletions core/analyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "analyzer.h"

std::string Analyzer::analyze(std::string path) {
AnalysisResult Analyzer::analyze(const std::string& path) {
reader_.OpenFile(path);

AnalysisResult res;
Expand All @@ -11,7 +11,6 @@ std::string Analyzer::analyze(std::string path) {
}

reader_.CloseFile();
std::string report = reporter_.GenerateTextReport(res);

return report;
}
return res;
}
4 changes: 1 addition & 3 deletions core/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
#include "reader.h"
#include "parser.h"
#include "statistics.h"
#include "reporter.h"
#include <string>

class Analyzer {
private:
Reader reader_;
Parser parser_;
Reporter reporter_;
Statistics statistics_;

public:
std::string analyze(std::string path);
AnalysisResult analyze(const std::string& path);
};

1 change: 0 additions & 1 deletion core/parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "parser.h"
#include <iostream>

LogFormat Parser::DetectFormat(const std::string& line) {
if (line.find("HTTP/1.0") != std::string::npos) {
Expand Down
23 changes: 23 additions & 0 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets)

qt_standard_project_setup()

qt_add_executable(log-analyzer-gui
main.cpp
menu_window.h
menu_window.cpp
menu_window.ui
main_window.h
main_window.cpp
main_window.ui
)

target_link_libraries(log-analyzer-gui PRIVATE
Qt6::Widgets
core_lib
)

qt_finalize_executable(log-analyzer-gui)
11 changes: 11 additions & 0 deletions gui/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <QApplication>
#include "menu_window.h"

int main(int argc, char *argv[]) {
QApplication app(argc, argv);
app.setApplicationName("Log analyzer");
MenuWindow window;
window.setWindowTitle("Menu");
window.show();
return app.exec();
}
Loading