diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-15 13:52:35 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-15 13:52:35 -0400 |
commit | ef6c4964c5b9c63ee3742a8ca1ebe3ab6515c16b (patch) | |
tree | 5463d6a198e820759782099feda3f42ac088fc31 /Utility | |
parent | b236c46dbb20cfbb42201b7cccdaa153b7bd2ed1 (diff) |
webapp: Now has a page to view the log, accessed from the control menu.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/LogFile.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Utility/LogFile.hs b/Utility/LogFile.hs index c45a1d405..1985b7eda 100644 --- a/Utility/LogFile.hs +++ b/Utility/LogFile.hs @@ -19,7 +19,7 @@ openLog logfile = do rotateLog :: FilePath -> Int -> IO () rotateLog logfile num - | num >= 10 = return () + | num > maxLogs = return () | otherwise = whenM (doesFileExist currfile) $ do rotateLog logfile (num + 1) renameFile currfile nextfile @@ -28,4 +28,15 @@ rotateLog logfile num nextfile = filename (num + 1) filename n | n == 0 = logfile - | otherwise = logfile ++ "." ++ show n + | otherwise = rotatedLog logfile n + +rotatedLog :: FilePath -> Int -> FilePath +rotatedLog logfile n = logfile ++ "." ++ show n + +{- Lists most recent logs last. -} +listLogs :: FilePath -> IO [FilePath] +listLogs logfile = filterM doesFileExist $ reverse $ + logfile : map (rotatedLog logfile) [1..maxLogs] + +maxLogs :: Int +maxLogs = 9 |