https://github.com/lis0x90/tslat
Enrich your log with timestamp delta
https://github.com/lis0x90/tslat
delta log logging timestamp
Last synced: about 1 year ago
JSON representation
Enrich your log with timestamp delta
- Host: GitHub
- URL: https://github.com/lis0x90/tslat
- Owner: lis0x90
- License: apache-2.0
- Created: 2018-09-21T18:11:01.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-29T13:53:12.000Z (almost 7 years ago)
- Last Synced: 2025-04-30T19:07:06.661Z (about 1 year ago)
- Topics: delta, log, logging, timestamp
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tslat
As of first step to do performance review of your application is look to your log files. But it may be so tedious to calc time delta between two adjacent log lines.
This tool is to resquie! It's calculates timestamp delta between to adjacent log lines and out in format you may specify.
Let's suppose we have following log lines in file:
```console
2018-09-21 14:43:59,832 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Get evolution scripts by: META-INF/dbevolution/accounting/.index
2018-09-21 14:43:59,845 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Got evolution files: List(1.sql, 2.sql, 3.sql, 4.sql)
2018-09-21 14:43:59,846 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Found: META-INF/dbevolution/accounting/1.sql
2018-09-21 14:43:59,852 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Found: META-INF/dbevolution/accounting/2.sql
```
And we want to see time delta between timestamps on each log line. We can estimate performance of each operation on high level, for example.
Download and run this nifty tool:
```console
$cat server.log | tslat -delta-format "%9d|"
0| 2018-09-21 14:43:59,832 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Get evolution scripts by: META-INF/dbevolution/accounting/.index
13| 2018-09-21 14:43:59,845 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Got evolution files: List(1.sql, 2.sql, 3.sql, 4.sql)
1| 2018-09-21 14:43:59,846 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Found: META-INF/dbevolution/accounting/1.sql
6| 2018-09-21 14:43:59,852 DEBUG [main] r.k.u.d.ClasspathScriptLocator - Found: META-INF/dbevolution/accounting/2.sql
```
I prefer to separate delta value from the rest of logs by `|` char, so I added parameter `-delta-format`. It's simplifies further logs processing by other tools like `sed` or `awk`.
# help
As usually:
```console
$ tslat --help
Usage of ./tslat:
-date-length int
Length of date string from line start (default 23)
-delta-format string
Timestamp delta output format in golang Sprinf() syntax (default "%9d")
-input string
Input file path. Stdin will be used if its option is ommited
-threshold int
Filter out lines with timestamp delta lesser than specified threshold
```
Note! All time deltas, if not stated others, is treated as microseconds.