https://github.com/msantos/tscat
Timestamp stdin to stdout/stderr
https://github.com/msantos/tscat
capsicum logging pledge seccomp setrlimit stdio timestamp
Last synced: 8 months ago
JSON representation
Timestamp stdin to stdout/stderr
- Host: GitHub
- URL: https://github.com/msantos/tscat
- Owner: msantos
- License: isc
- Created: 2020-09-06T11:02:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-29T12:05:59.000Z (11 months ago)
- Last Synced: 2025-03-29T13:22:08.232Z (11 months ago)
- Topics: capsicum, logging, pledge, seccomp, setrlimit, stdio, timestamp
- Language: C
- Homepage:
- Size: 65.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SYNOPSIS
tscat *option* [*label*]
# DESCRIPTION
tscat: timestamp stdin to stdout/stderr
tscat timestamps standard input and writes the output to standard output,
standard error or both.
# EXAMPLES
```
$ echo test | tscat
2020-10-11T07:09:13-0400 test
$ echo test | tscat foo
2020-10-11T07:09:15-0400 foo test
# duplicate output to stdout/stderr
$ echo test | tscat -o 3 foo
2020-10-11T07:09:15-0400 foo 2020-10-11T07:09:15-0400 foo test
test
$ echo test | tscat -o 3 foo > /dev/null
2020-10-11T07:09:15-0400 foo test
$ echo test | tscat -o 3 foo 2> /dev/null
2020-10-11T07:09:15-0400 foo test
```
# Build
```
make
# selecting process restrictions
RESTRICT_PROCESS=seccomp make
#### using musl
RESTRICT_PROCESS=rlimit ./musl-make
## linux seccomp sandbox: requires kernel headers
# clone the kernel headers somewhere
export MUSL_INCLUDE=/tmp
git clone https://github.com/sabotage-linux/kernel-headers.git $MUSL_INCLUDE/kernel-headers
# then compile
./musl-make clean all
```
# OPTIONS
-o, --output *1|2|3*
: stdout=1, stderr=2, both=3 (default: 1)
-f, --format *fmt*
: timestamp format (see strftime(3)) (default: `%F%T%z`)
-W, --write-error *exit|drop|block*
: behaviour if write buffer is full (default: block)
-h, --help
: usage summary
# ALTERNATIVES
```shell
#!/bin/sh
LABEL="${1-""}"
exec awk -v service="$LABEL" '{
t = strftime("%FT%T%z")
printf("%s %s %s\n", t, service, $0) > "/dev/stderr"
printf("%s %s %s\n", t, service, $0)
fflush()
}'
```