Last active
December 21, 2015 13:28
-
-
Save zsol/6312408 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Data.Text as T | |
import qualified Data.Text.IO as T | |
import Data.Time | |
import System.Exit | |
import System.IO.Error | |
import System.Locale | |
format :: String | |
format = "%Y-%m-%d %H:%M:%S,%q" | |
-- 2013-08-22 10:21:15,577564000000 | |
-- last character we need is -^ | |
truncatePicoSeconds :: [a] -> [a] | |
truncatePicoSeconds = take 23 | |
main :: IO () | |
main = do | |
localTZ <- getCurrentTimeZone | |
loop localTZ | |
loop :: TimeZone -> IO b | |
loop tz = do | |
logLine <- T.getLine `catchIOError` \e -> if isEOFError e then exitSuccess else ioError e | |
time <- getCurrentTime | |
let localTime = utcToLocalTime tz time | |
formattedTime = T.pack $ truncatePicoSeconds $ formatTime defaultTimeLocale format localTime | |
T.putStrLn $ " " `T.intercalate` [formattedTime, logLine] | |
loop tz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: fcat | |
description: Formatted cat - adds timestamps to standard input | |
build: | |
lucid: | |
run: &runcommands | | |
ls /etc/profile.d/haskell* >/dev/null 2>/dev/null && . /etc/profile.d/haskell* | |
set -e | |
ghc --make fcat.hs | |
mkdir -p usr/local/bin | |
mv fcat usr/local/bin/ | |
# all this shit doesn't work reliably right now | |
# but this is the general idea | |
# which gem || . $HOME/.rvm/scripts/rvm | |
# which fpm || gem install fpm | |
# fpm -t deb -s dir -n ${JOB_NAME} -m zsol@prezi.com --description "Formatted cat - adds timestamps to standard input" --url "https://gist.github.com/zsol/6312408" -v ${BUILD_NUMBER} usr | |
artifacts: &artifacts "usr/local/bin/fcat" | |
precise: | |
run: *runcommands | |
artifacts: *artifacts | |
pinned: precise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment