{"id":19071079,"url":"https://github.com/mokiat/preftime","last_synced_at":"2025-04-28T15:30:07.089Z","repository":{"id":57634496,"uuid":"93827961","full_name":"mokiat/preftime","owner":"mokiat","description":"Add timestamp prefixes to command outputs","archived":false,"fork":false,"pushed_at":"2023-03-21T21:20:50.000Z","size":12,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T17:19:37.293Z","etag":null,"topics":["command-line","golang","timestamp","tool"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mokiat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-09T06:48:18.000Z","updated_at":"2024-01-08T10:47:50.000Z","dependencies_parsed_at":"2024-11-09T01:24:24.576Z","dependency_job_id":"8546e06d-24bf-484b-9f2b-fa02e8bae8b1","html_url":"https://github.com/mokiat/preftime","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fpreftime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fpreftime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fpreftime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mokiat%2Fpreftime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mokiat","download_url":"https://codeload.github.com/mokiat/preftime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251338425,"owners_count":21573555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","golang","timestamp","tool"],"created_at":"2024-11-09T01:22:14.543Z","updated_at":"2025-04-28T15:30:07.061Z","avatar_url":"https://github.com/mokiat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# preftime\n\n![Build Status](https://github.com/mokiat/preftime/workflows/Go/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mokiat/preftime)](https://goreportcard.com/report/github.com/mokiat/preftime)\n\nPreftime is a tool that allows you to prefix the output of another program with timestamp information.\n\nIdeally, the program you are running should have the capability to log timestamps on its own. Alternatively, you could check whether you terminal supports such a feature. However, I have been in situations where neither option was available. I ended up writing these few lines of code and decided to share it with anyone who may need it.\n\nIf you have a Go development environment set up, you can use the following command to acquire the tool.\n\n```sh\ngo install github.com/mokiat/preftime@latest\n```\n\nOtherwise, there are pre-built versions of the tool available in the [Releases](https://github.com/mokiat/preftime/releases) section of this project.\n\nYou would use the tool as follows.\n\n```sh\n\u003ccommand\u003e 2\u003e\u00261 | preftime\n```\n\nThe `2\u003e\u00261` part is optional. It just assures that both stdout and stderr go through `preftime`.\n\nAs an alternative, you could do the following.\n\n```sh\n\u003ccommand\u003e \u003e \u003e(preftime) 2\u003e \u003e(preftime)\n```\n\nThis redirects both stdout and stderr to preftime. The `\u003e(preftime)` part makes `preftime` behave like a writable file.\n\nFollowing the same logic, you could have your bash script redirect it's output to preftime.\n\n```sh\n#!/bin/bash -e\n\nexec \u003e \u003e(preftime)\nexec 2\u003e \u003e(preftime)\n\n\u003ccommand1\u003e\n\u003ccommand2\u003e\n```\n\nFor example, here is a real-life simple usage scenario.\n\n```sh\n$ host example.org | preftime\n[2017-06-25 15:42:00.664] example.org has address 93.184.216.34\n[2017-06-25 15:42:00.665] example.org has IPv6 address 2606:2800:220:1:248:1893:25c8:1946\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmokiat%2Fpreftime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmokiat%2Fpreftime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmokiat%2Fpreftime/lists"}