Skip to content

pedrolopesme/vacuum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logs Vacuum Cleaner

A small and configurable logs cleaner tool.

Features

Logs Vacuum Cleaner is a small and flexible (i.e. configurable) tool created to remove old log files, allowing you to keep them compressed in a single file and/or permanently remove them.

Generally, the Logs Vacuum Cleaner is applicable whenever:

  • Your application(s) generates multiple log files and there isn't a post process to deal with them
  • You want to be able to compress a set of log files using a compression algorithm of choice.
  • You have more than one directory storing logs and you want a centralized way to purge them.
  • You want to discard old, non-compressed files.

Configuration

Getting right to the point, configurations are stored at ./config/vacuums.json dir. This is a complete configuration example:

{
    "vacuums" : [
        {
            "path" : "/some/log/path/",
            "filesPrefix" : "server*",
            "filesSuffix" : "*.log",
            "removeLogs" : true,
            "compressor" : "tar.gz",
            "outputPath" : "/some/backup/path/",
            "outputName" : "logs.2006-01.tag.gz",
            "updateOutput" : true
        }
    ]
}

Where:

- path

The Base path where the logs are stored. Required.

- filesPrefix

Files prefix. Accepts wildcard *. Under *nix systems you can speficy more than one pattern using braces. Ex: {log-*,access-*,error-*} Not required.

- filesSuffix

Files suffix. Accepts wildcard *. Under *nix systems you can speficy more than one pattern using braces. Ex: {*.log,*.txt,*.output} Not required.

- removeLogs

Should the Vacuum remove found logs after merging and compress them? Not required.

- compressor

Compression algorithm. Only tar.gz is supported at the moment. Required.

- outputPath

Output path where the compressed file will be stored. Required.

- outputName

Output file name where the compressed file will be stored. Accepts Go Time format parameters. Required.

- updateOutput

If the vacuum finds a previously generated output, should it just update the output file (by appending new log files) ? Not Required, default false.

Makefile

This project provides a Makefile with all common operations need to develop, test and build call-it.

  • build: generates binaries
  • test: runs all tests
  • clean: removes binaries
  • run: executes main func

Develop using Docker

To build a docker image, you should just simply type:

$ docker build --rm -t somedir/logs-vacuum .

In order to run it, simply do:

$ docker run somedir/logs-vacuum

Running tests

Tests were write using Go testing. In order to run them, just type:

$ go test

Generating builds

Under scripts/ dir you can regenerate builds using generate-builds.sh script file. Currently, we are exporting LogsVacuum to the following systems/archs:

  • linux/386
  • linux/amd64
  • linux/arm
  • macos (darwin)/386
  • macos (darwin)/amd64
  • windows/386
  • windows/amd64

The latest builds can be found at /dist dir.

License

MIT. Copyright (c) Pedro Mendes.