-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First attempt at logging to files instead of std out #135
Changes from 1 commit
f7d35eb
efcfb7e
9b29a75
211533f
447934f
eac7f2e
0235a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ cabal.sandbox.config | |
.envrc | ||
dist-newstyle/ | ||
result/ | ||
logs/ |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,6 +37,7 @@ import System.Console.GetOpt ( ArgDescr(..) | |||||
, getOpt | ||||||
, usageInfo | ||||||
) | ||||||
import System.Directory ( createDirectoryIfMissing ) | ||||||
import System.Environment ( getArgs ) | ||||||
import System.IO ( stdout ) | ||||||
import Web.Scotty ( get | ||||||
|
@@ -54,6 +55,7 @@ opts :: [OptDescr (Config -> Config)] | |||||
opts = | ||||||
[ Option [] ["help"] (NoArg (set cHelp True)) "Show usage info" | ||||||
, Option [] ["port"] (ReqArg (set cPort . read) "PORT") "Port to run on" | ||||||
, Option [] ["path"] (ReqArg (set cLogPath) "PATH") "Path to save log files to, default is 'logs'" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Columns <3 |
||||||
, Option [] | ||||||
["interval"] | ||||||
(ReqArg (set cInterval . (1000000 *) . read) "INTERVAL (s)") | ||||||
|
@@ -71,6 +73,7 @@ main = (recreateConfig . getOpt Permute opts <$> getArgs) >>= \case | |||||
(config , _ , _ ) -> do | ||||||
upd <- newEmptyMVar -- putMVar when to update | ||||||
viewRef <- createViewReference | ||||||
createDirectoryIfMissing True (_cLogPath config) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this path relative? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe both? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both absolute and relative that is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It handles both :D 🗡️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWESOME! I am now a much calmer human. |
||||||
|
||||||
-- In the list there are three items running concurrently: | ||||||
-- 1. Timer that sends a signal to the updater when it's time to update | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,18 +31,14 @@ import Data.IORef ( IORef | |||||||||
, writeIORef | ||||||||||
) | ||||||||||
import Data.Foldable ( for_ ) | ||||||||||
import Data.Text.Lazy ( fromStrict | ||||||||||
, pack | ||||||||||
) | ||||||||||
import Prettyprinter ( Doc | ||||||||||
, pretty | ||||||||||
) | ||||||||||
import Data.Text.Lazy ( fromStrict ) | ||||||||||
import Prettyprinter ( Doc ) | ||||||||||
import Data.AffineSpace ( (.+^) ) | ||||||||||
import Data.Thyme ( _localDay | ||||||||||
, _localTimeOfDay | ||||||||||
, _todHour | ||||||||||
, _zonedTimeToLocalTime | ||||||||||
, getZonedTime | ||||||||||
, getZonedTime, getCurrentTime | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newlines and lexicographic ordering <3 |
||||||||||
) | ||||||||||
import Lens.Micro.Platform ( (^.) | ||||||||||
, (&) | ||||||||||
|
@@ -56,6 +52,7 @@ import Model.Types | |||||||||
import Model.Karen | ||||||||||
import Model.Wijkanders | ||||||||||
import Model.Linsen | ||||||||||
import Text.Printf (printf) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor indentation fix
Suggested change
|
||||||||||
|
||||||||||
-- | Refreshes menus. | ||||||||||
-- The refresh function evaluates to `Some monad m => m (View model, Update signal)`, | ||||||||||
|
@@ -112,7 +109,9 @@ update = do | |||||||||
|
||||||||||
for_ rest $ \r -> case menu r of | ||||||||||
Left e -> | ||||||||||
logMessage =<< timestamp (pretty $ name r <> ": " <> pack (show e)) | ||||||||||
asks _cLogPath >>= \path -> | ||||||||||
liftIO getCurrentTime >>= | ||||||||||
liftIO . flip writeFile (show e) . flip (printf "%s/%s%s.txt" path) (name r) . show | ||||||||||
Right _ -> pure () | ||||||||||
|
||||||||||
return (View rest textday d) | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 IT EXISTS FOR REAL! 🎉