Skip to content

Commit

Permalink
build: doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
thefab committed Mar 24, 2020
1 parent dc6bdba commit b4995ec
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 26 deletions.
File renamed without changes.
79 changes: 53 additions & 26 deletions .metwork-framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,38 @@ It can be used to avoid loosing some logs if you use `logrotate` with `copytrunc
- [x] configurable with CLI options as well with env variables
- [x] usable as a wrapper to capture stdout and stderr (`log_proxy_wrapper --stdout=/log/myapp.stdout --stderr=/log/myapp.stderr -- myapp myapp_arg1 myapp_arg2`)
- [x] usable as a wrapper to capture stdout and stderr in the same file (`log_proxy_wrapper --stdout=/log/myapp.log --stderr=STDOUT -- myapp myapp_arg1 myapp_arg2`)
- [x] very few dependencies (only `glib2` is required)
- [x] very few dependencies (only `glib2` is required)
- [x] very easy to build (event on old distributions like `CentOS 6`)

## How to install?

We provide Linux 64 bits binaries in [releases section](https://github.com/metwork-framework/log_proxy/releases). There is virtually no requirement (you just need a Linux 64 bits distribution more recent than CentOS 6 (2011!)).

Of course, you can also build the tool by yourself (see at the end of this document).

To install the binary distribution:

```
# As root user (or with sudo)
cd /opt
wget -O log_proxy-linux64-v0.0.8.tar.gz "https://github.com/metwork-framework/log_proxy/releases/download/v0.0.8/log_proxy-linux64-v0.0.8.tar.gz"
zcat log_proxy-linux64-v0.0.8.tar.gz |tar xvf -
ln -s log_proxy-linux64-v0.0.8 log_proxy
```

You can now use it with absolute path `/opt/log_proxy/bin/log_proxy` and `opt/log_proxy/bin/log_proxy_wrapper`.

For a more convenient way, configure your `PATH` to prepend the `/opt/log_proxy/bin` path. For example (maybe you would have to adapt this to your specific Linux distribution):

```
cat >/etc/profile.d/log_proxy.sh <<EOF
# Add log_proxy directory to PATH
export PATH="/opt/log_proxy/bin:${PATH}"
EOF
```

After a restart of your terminal, you should use `log_proxy` directly by its name.

## Why this tool?

### Why not using `logrotate` with `copytruncate` feature?
Expand All @@ -39,7 +68,7 @@ If you use `myapp myapp_arg1 myapp_arg2 >/log/myapp.log 2>&1`for example and if

> Please note also that copyrotate has an inherent race condition, in that it's possible that the writer will append a line to the logfile just after logrotate finished the copy and before it has issued the truncate operation. That race condition would cause it to lose those lines of log forever. That's why rotating logs using copytruncate is usually not recommended, unless it's the only possible way to do it.
### Why developping another tool?
### Why developing another tool?

After reading: https://superuser.com/questions/291368/log-rotation-of-stdout and http://zpz.github.io/blog/log-rotation-of-stdout/, we reviewed plenty of existing tools (`multilog`, `rotatelogs`, `piper`...).

Expand All @@ -51,28 +80,6 @@ But none of them was ok with our needed features:

The [piper tool](https://github.com/gongled/piper) was the more close but does not support the last feature (several instances to the same log file).

## Build & Install

### Requirements

A Linux/Unix distribution with standard development tools (`git`, `gcc`, `make`, `pkg-config`) and `glib2` library with `devel` support (provided for example in CentOS 6 in the `glib2-devel` standard package).

### Build

```console
git clone https://github.com/metwork-framework/log_proxy # or download/unpack a zip with the github interface
cd log_proxy
make
```

### Install

Then as `root` user or prefixed with `sudo`:

```console
make PREFIX=/usr/local install
```

## Usage

### As a filter
Expand Down Expand Up @@ -100,14 +107,14 @@ Application Options:
-f, --fifo if set, read lines on this fifo instead of stdin
-r, --rm-fifo-at-exit if set, drop fifo at then end of the program (you have to use --fifo option of course)

Optional environment variables to override defaults :
Optional environment variables to override defaults :
LOGPROXY_ROTATION_SIZE
LOGPROXY_ROTATION_TIME
LOGPROXY_ROTATION_SUFFIX
LOGPROXY_ROTATED_FILES

Example for rotation-size option :
- If log_proxy is run with the option --rotation-size on command line, rotation-size will take the provided value
- If log_proxy is run with the option --rotation-size on command line, rotation-size will take the provided value
- If the option --rotation-size is not provided on command line :
- If the environment variable LOGPROXY_ROTATION_SIZE is set, rotation-size will take this value
- If the environment variable LOGPROXY_ROTATION_SIZE is not set, rotation-size will take the default value 104857600
Expand Down Expand Up @@ -138,3 +145,23 @@ Application Options:
-O, --stdout stdout file path (NULL string (default) can be used to redirect to /dev/null)
-E, --stderr stderr file path (STDOUT string (default) can be used to redirect to the same file than stdout)
```

## How to build?

### Requirements

A Linux/Unix distribution with standard development tools (`git`, `gcc`, `make`, `pkg-config`) and `glib2` library with `devel` support (provided for example in CentOS 6 in the `glib2-devel` standard package).

### Build and install

```console
git clone https://github.com/metwork-framework/log_proxy # or download/unpack a zip with the github interface
cd log_proxy
make
```

Then as `root` user or prefixed with `sudo`:

```console
make PREFIX=/usr/local install
```

0 comments on commit b4995ec

Please sign in to comment.