From c46487ac7c51a8be8aff8a07d2b5ea4c6b4bbc7a Mon Sep 17 00:00:00 2001 From: Rapturate Date: Mon, 19 Oct 2026 19:16:59 -0400 Subject: [PATCH] added a windows build script and updated the README.md for proper markdown formatting --- README.md | 60 +++++++++++++++++++++++++++++++++++------------ scripts/build.ps1 | 40 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 15 deletions(-) create mode 100644 scripts/build.ps1 diff --git a/README.md b/README.md index db1a07d..667b0ea 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,50 @@ -LumberJack TUI takes in an Apache2 access log file and provides an interactive interface to check your logs. +# LumberJack TUI -MacOS Users: -- Unfortunately, I don't want to have to setup my pc to build your executable for you. So, the CMakeLists.txt file will autobuild an executable for you :) +LumberJack TUI reads Apache 2 access logs and provides an interactive interface for exploring them. -All Other Users: -- I have packaged executables into the released .zip files +## Building on Windows -NOTES: -- The TUI will ask for the access.log file location and the GeoLite2-City.mmdb file location on startup. It will then create local lumberjack.config file with the locations you provided. If you mess up, just change them in the lumberjack.config for now. - * I have not tried using the GeoLite2-Country.mmdb file and do not know if it will crash the application... -- Log line format example: - 172.71.245.109 - - [23/Jan/2016:09:49:24 +0100] "GET /favicon.ico HTTP/1.1" 301 642 "-" "Mozilla/5.0 (Linux; Android 10; arm64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/15.0.0.0 Safari/537.36" - * This is the only format I have setup for the regex so far. It works on both my Apache2 and Gitea access logs but I do not know a whole lot about access log formats. +You need CMake, Ninja, and MinGW-w64 with `g++` available on your `PATH`. + +From the repository root, run: + +```powershell +.\scripts\build.ps1 +``` + +This builds the Release executable. To build Debug or choose a different build directory, use: + +```powershell +.\scripts\build.ps1 -Configuration Debug +.\scripts\build.ps1 -BuildDirectory build-custom +``` + +By default, the executable is written to `build\bin\release\LumberJack.exe`. + +## Other platforms + +- **macOS:** CMake is configured to build the executable for you. +- **Other users:** Prebuilt executables are available in the ZIP files under [`Releases`](Releases/). + +## Configuration + +On startup, the TUI asks for the locations of your `access.log` file and `GeoLite2-City.mmdb` database. It saves these locations to `lumberjack.config`; edit that file if you need to correct them. + +The `GeoLite2-Country.mmdb` database has not been tested and may not work. + +## Supported log format + +The parser currently expects an Apache-style access log format, such as: + +```text +172.71.245.109 - - [23/Jan/2016:09:49:24 +0100] "GET /favicon.ico HTTP/1.1" 301 642 "-" "Mozilla/5.0 (Linux; Android 10; arm64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/15.0.0.0 Safari/537.36" +``` + +This format has been tested with Apache 2 and Gitea access logs. Other formats may not be parsed correctly. + +## Planned improvements -FUTURE CHANGES: - Ban IP functionality -- Live .log file changing -- Refactor config.cpp to find .log files from a dierectory -- Add a function to unarchive, archived logs. +- Live `.log` file updates +- Find `.log` files in a directory from `config.cpp` +- Unarchive archived logs diff --git a/scripts/build.ps1 b/scripts/build.ps1 new file mode 100644 index 0000000..7f4fc77 --- /dev/null +++ b/scripts/build.ps1 @@ -0,0 +1,40 @@ +param( + [ValidateSet("Debug", "Release")] + [string]$Configuration = "Release", + [string]$BuildDirectory = "build" +) + +$ErrorActionPreference = "Stop" + +if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) { + Write-Error "CMake was not found. Install CMake and ensure it is on PATH." + exit 1 +} + +$sourceDirectory = Split-Path -Parent $PSScriptRoot +if ([System.IO.Path]::IsPathRooted($BuildDirectory)) { + $buildPath = $BuildDirectory +} else { + $buildPath = Join-Path $sourceDirectory $BuildDirectory +} + +$configureArgs = @( + "-S", $sourceDirectory, + "-B", $buildPath, + "-G", "Ninja", + "-DCMAKE_CXX_COMPILER=g++", + "-DCMAKE_BUILD_TYPE=$Configuration" +) + +& cmake @configureArgs +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} + +& cmake --build $buildPath --config $Configuration +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} + +$outputPath = Join-Path $buildPath "bin\$($Configuration.ToLowerInvariant())\LumberJack.exe" +Write-Host "Build complete: $outputPath"