Skip to content

Commit

Permalink
Setup logs
Browse files Browse the repository at this point in the history
Summary: Fixes #41

Reviewed By: niteria

Differential Revision: D5242794

fbshipit-source-id: cd53bd6
  • Loading branch information
patapizza authored and facebook-github-bot committed Jun 14, 2017
1 parent b943111 commit 3ec2228
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.stack-work/
log/
24 changes: 19 additions & 5 deletions exe/ExampleMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,46 @@

{-# LANGUAGE OverloadedStrings #-}

import Prelude
import Control.Applicative
import Control.Arrow ((***))
import Control.Monad (unless)
import Control.Monad.IO.Class
import Data.Aeson
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as LBS
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Data.Time.LocalTime.TimeZone.Series
import Data.String
import Prelude
import System.Directory
import TextShow
import Text.Read (readMaybe)
import qualified Data.ByteString.Lazy as LBS
import qualified Data.HashMap.Strict as HashMap
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text

import Snap.Core
import Snap.Http.Server

import Duckling.Core
import Duckling.Data.TimeZone

createIfMissing :: FilePath -> IO ()
createIfMissing f = do
exists <- doesFileExist f
unless exists $ writeFile f ""

setupLogs :: IO ()
setupLogs = do
createDirectoryIfMissing False "log"
createIfMissing "log/error.log"
createIfMissing "log/access.log"

main :: IO ()
main = do
setupLogs
tzs <- loadTimeZoneSeries "/usr/share/zoneinfo/"
quickHttpServe $
ifTop (writeBS "quack!") <|>
Expand Down

0 comments on commit 3ec2228

Please sign in to comment.