Skip to content

Commit 4bfe0b8

Browse files
authored
Merge pull request #10 from thecasualcoder/move-to-hourglass-from-chrono
Detect source timezone and target timezone
2 parents 3ea17e0 + af48386 commit 4bfe0b8

File tree

9 files changed

+542
-324
lines changed

9 files changed

+542
-324
lines changed

.travis.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: rust
2+
sudo: required
23

34
rust:
45
- stable
@@ -10,6 +11,16 @@ matrix:
1011
- rust: nightly
1112
fast_finish: true
1213

14+
env:
15+
global:
16+
- TZ=Asia/Kolkata
17+
18+
before_script:
19+
- echo 'Asia/Kolkata' | sudo tee /etc/timezone
20+
- sudo dpkg-reconfigure --frontend noninteractive tzdata
21+
- sudo ln -snf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
22+
1323
script:
14-
- cargo build --verbose --all
15-
- cargo test --verbose --all
24+
- date
25+
- cargo build --all
26+
- cargo test --all

Cargo.lock

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "tztail"
3-
version = "0.1.1"
3+
version = "1.0.0"
44
authors = ["Aswin Karthik <aswinkarthik93@gmail.com>"]
55

66
[dependencies]
77
regex = "1"
8+
hourglass = "0.*"
89
chrono = "0.4"
910
chrono-tz = "0.5"
10-
lazy_static = "1.1.0"
1111

1212
[dependencies.clap]
1313
version = "2"

README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,47 @@
44

55
tztail (TimeZoneTAIL) allows you to view logs in the timezone you want.
66

7-
> This project is work in progress
8-
97
## Usage
108

119
```bash
12-
tztail 0.1.1
10+
$ tztail --help
11+
tztail 1.0.0
1312
tztail (TimeZoneTAIL) allows you to view logs in the timezone you want
1413

1514
USAGE:
16-
tztail --timezone <TIMEZONE> [FILE]
15+
tztail [FILE]
1716

1817
OPTIONS:
19-
-t, --timezone <TIMEZONE> Sets the timezone in which output should be printed
20-
-f, --format <FORMAT> Custom format for parsing dates
18+
-t, --timezone <TIMEZONE> Sets the timezone in which output should be printed. (Default: local timezone)
19+
-f, --format <FORMAT> Custom format for parsing dates. (Default: autodetected patterns)
2120
-h, --help Prints help information
2221
-V, --version Prints version information
2322

2423
ARGS:
25-
<FILE> File to tail
24+
<FILE> File to tail. STDIN by default
2625
```
2726

27+
## Features
28+
29+
- Supports few standard formats with which auto detection is done when parsing logs.
30+
- Supports specifying custom format for parsing in case it is a non-standard format. See [here](https://docs.rs/chrono/0.4.6/chrono/format/strftime/index.html#specifiers) for formats.
31+
- Autodetect source timezone if present in logs. Example (`2014-11-28T12:00:09+0100` is CET)
32+
- Output logs to local timezone by default
33+
34+
## Demo
35+
36+
![demo](/demo/tztail.gif)
37+
38+
## Autodetectable formats
39+
40+
Most used autodetectable formats
41+
42+
| Name | Example |
43+
| --------------------- | ------------------------------- |
44+
| RFC2822 | Fri, 28 Nov 2014 12:00:09 +0000 |
45+
| RFC3339 | 2014-11-28T12:00:09+0000 |
46+
| Nginx Log format | 04/Nov/2018:12:13:49 |
47+
2848
## Usecase
2949

3050
This tool can be used to convert timestamps in a log to any desired timezone while tailing logs. Eg. In case your logs are in UTC and you want to view it in a different timezone say. Asia/Kolkata (IST), pipe the logs through `tztail`.
@@ -53,19 +73,6 @@ $ cat somelog | tztail -t Asia/Kolkata -f "%Y-%m-%d %H:%M:%S"
5373
2018-11-04 01:37:20 mvcc: finished scheduled compaction at 106120 (took 933.25µs)
5474
```
5575

56-
## Features
57-
58-
- Supports few standard formats with which auto detection is done when parsing logs.
59-
- Supports specifying custom format for parsing in case it is a non-standard format. See [here](https://docs.rs/chrono/0.4.6/chrono/format/strftime/index.html#specifiers) for formats.
60-
61-
## Autodetectable formats
62-
63-
| Name | Example |
64-
| --------------------- | ------------------------------- |
65-
| RFC2822 | Fri, 28 Nov 2014 12:00:09 +0000 |
66-
| RFC3339 | 2014-11-28T12:00:09+00:00 |
67-
| Nginx Log format | 04/Nov/2018:12:13:49 |
68-
| %Y-%m-%d %H:%M:%S.%6f | 2018-11-03 12:19:36.361297 |
6976

7077
## Building from source
7178

@@ -90,8 +97,8 @@ $ cargo test
9097
* [x] Support all standard datetime formats.
9198
* [x] Allow custom datetime format.
9299
* [x] Add option to read from file.
93-
* [ ] Allow specifying source timezone (currently supports only UTC).
94-
* [ ] Auto-detect source timezone if possible.
100+
* [x] Auto-detect source timezone if possible.
101+
* [ ] Allow specifying source timezone explicitely.
95102
* [ ] Support GCP/AWS cloud logging formats.
96103
* [ ] Performance optimizations
97104
* [ ] Add support to pass time-window which would only show the logs in that time period

demo/tztail.gif

591 KB
Loading

0 commit comments

Comments
 (0)