Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msantos/tscat
Timestamp stdin to stdout/stderr
https://github.com/msantos/tscat
capsicum logging pledge seccomp setrlimit stdio timestamp
Last synced: 16 days 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 (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-17T12:24:00.000Z (about 1 year ago)
- Last Synced: 2023-11-18T14:10:14.539Z (almost 1 year ago)
- Topics: capsicum, logging, pledge, seccomp, setrlimit, stdio, timestamp
- Language: C
- Homepage:
- Size: 54.7 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/shLABEL="${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()
}'
```