diff --git a/README.md b/README.md index c4dc726..1533314 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,97 @@ -You can stream and read files to a sentry DSN glitchtip or sentry itself I was fed up with how brittle sentry-cli was so I made this. +Certainly! Here is the updated README without the mentions of license or contributions: -I might get around to making a whole CI/CD process for this which will upload the executables properly at some point and make this public. -# Go Glitch +# Inotify-Glitch -Go Glitch is a command-line utility that reads log messages from a file or stdin and sends them to Glitchtip, a self-hosted Sentry-compatible error tracking system. +Inotify-Glitch is a command-line utility that reads log messages from files and sends them to Glitchtip, a self-hosted Sentry-compatible error tracking system. This tool provides a more reliable alternative to `sentry-cli` for streaming and reading log files. ## Installation To install the binary locally, you can use the provided installation script. Run the following command in your terminal: ```sh -curl -sSL https://git.nixc.us/Nixius/go-glitch/raw/branch/master/install.sh | bash +curl -sSL https://git.nixc.us/colin/inotify-glitch/raw/branch/master/install.sh | bash ``` -This will download and install the Go Glitch binary to your local machine. +This will download and install the Inotify-Glitch binary to your local machine. ## Usage -You can use Go Glitch by specifying a log file as an argument or by piping input to it. +You can use Inotify-Glitch by specifying log files through environment variables. -### Using a Log File +### Setting Up Environment Variables -```sh -go-glitch /path/to/logfile -``` +Inotify-Glitch requires the `GLITCHTIP_DSN` environment variable to be set with your Glitchtip DSN and the `LOG_FILES` environment variable to list the log files to monitor. -### Using Piped Input +#### Shell Environment -```sh -cat /path/to/logfile | go-glitch -``` - -## Configuration - -Go Glitch requires the `GLITCHTIP_DSN` environment variable to be set with your Glitchtip DSN. You can set this environment variable in your shell environment, Dockerfile, or `docker-compose.yml` file. - -### Shell Environment - -Add the following line to your `.zshrc` or `.bashrc` file: +Add the following lines to your `.zshrc` or `.bashrc` file: ```sh export GLITCHTIP_DSN="your-glitchtip-dsn" +export LOG_FILES="path/to/logfile1,path/to/logfile2" ``` -After adding the line, reload your shell configuration: +After adding these lines, reload your shell configuration: ```sh source ~/.zshrc # for zsh users source ~/.bashrc # for bash users ``` -### Dockerfile +#### Dockerfile -If you are using a Docker container, add the environment variable in your `Dockerfile`: +If you are using a Docker container, add the environment variables in your `Dockerfile`: ```Dockerfile ENV GLITCHTIP_DSN=your-glitchtip-dsn +ENV LOG_FILES=/path/to/logfile1,/path/to/logfile2 ``` -### docker-compose.yml +#### docker-compose.yml -If you are using Docker Compose, add the environment variable in your `docker-compose.yml` file: +If you are using Docker Compose, add the environment variables in your `docker-compose.yml` file: ```yaml version: '3.8' services: - go-glitch: + inotify-glitch: image: your-docker-image environment: - GLITCHTIP_DSN=your-glitchtip-dsn + - LOG_FILES=/path/to/logfile1,/path/to/logfile2 ``` + +## Running Inotify-Glitch + +Once you have set up the necessary environment variables, you can start Inotify-Glitch to monitor the specified log files. + +### Running Directly + +```sh +inotify-glitch +``` + +### Example: Appending an Error Line to a Log File + +To see Inotify-Glitch in action, append an error line to one of the monitored log files: + +```sh +echo "This is an error line" >> /path/to/logfile1 +``` + +Inotify-Glitch will detect the change and send the error message to Glitchtip. + +## Development and CI/CD + +This project aims to provide a more reliable logging solution. In the future, I plan to set up a CI/CD process that will upload the executables automatically and make this project public. + +### Debug Mode + +To enable debug mode, set the `DEBUG` environment variable: + +```sh +export DEBUG=true +``` + +This will enable more detailed logging to help troubleshoot issues. \ No newline at end of file diff --git a/test.sh b/test.sh index 824048b..14de440 100755 --- a/test.sh +++ b/test.sh @@ -14,9 +14,28 @@ echo "Creating test log files..." echo "Initial log content" > test_log_1.log echo "Initial log content" > test_log_2.log +# Determine the OS and architecture +OS="$(uname -s | tr '[:upper:]' '[:lower:]')" +ARCH="$(uname -m)" + +case $ARCH in + x86_64) ARCH="amd64" ;; + arm64 | aarch64) ARCH="arm64" ;; + arm*) ARCH="arm/v7" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; +esac + +BINARY="./dist/inotify-glitch_${OS}_${ARCH}" + +# Check if the binary exists +if [ ! -f "$BINARY" ]; then + echo "Binary for ${OS}_${ARCH} not found. Please ensure the correct binary is present." + exit 1 +fi + # Run the Go program in the background -echo "Starting the Go program..." -./dist/inotify-glitch_darwin_arm64 & +echo "Starting the Go program: $BINARY" +$BINARY & # Capture the PID of the Go program GO_PID=$! @@ -24,15 +43,18 @@ GO_PID=$! # Give the program a moment to start sleep 2 -# Append a line with an error to one of the log files +# Append a different error line to each log file echo "Appending error line to test_log_1.log..." -echo "This is an error line" >> test_log_1.log +echo "Error in log 1: Test error message 1" >> test_log_1.log -# Give the program some time to process the change -sleep 2 +echo "Appending error line to test_log_2.log..." +echo "Error in log 2: Test error message 2" >> test_log_2.log -# Check if the Go program detected the change (you can enhance this section with more specific checks) -echo "Check the logs to verify the program detected the error line." +# Give the program some time to process the changes +sleep 5 + +# Check if the Go program detected the changes (you can enhance this section with more specific checks) +echo "Check the logs to verify the program detected the error lines." # Capture Go program logs for debugging ps -p $GO_PID > /dev/null