webapp: Now has a page to view the log, accessed from the control menu.
This commit is contained in:
parent
d7ca6fb856
commit
e15cca7db8
6 changed files with 31 additions and 2 deletions
|
@ -11,6 +11,7 @@ module Assistant.WebApp.Control where
|
|||
|
||||
import Assistant.WebApp.Common
|
||||
import Locations.UserConfig
|
||||
import Utility.LogFile
|
||||
|
||||
import Control.Concurrent
|
||||
import System.Posix (getProcessID, signalProcess, sigTERM)
|
||||
|
@ -40,3 +41,10 @@ getRestartR = page "Restarting" Nothing $ do
|
|||
where
|
||||
restartcommand program = program ++ " assistant --stop; " ++
|
||||
program ++ " webapp"
|
||||
|
||||
getLogR :: Handler RepHtml
|
||||
getLogR = page "Logs" Nothing $ do
|
||||
logfile <- lift $ runAnnex undefined $ fromRepo gitAnnexLogFile
|
||||
logs <- liftIO $ listLogs logfile
|
||||
logcontent <- liftIO $ concat <$> mapM readFile logs
|
||||
$(widgetFile "control/log")
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/shutdown ShutdownR GET
|
||||
/shutdown/confirm ShutdownConfirmedR GET
|
||||
/restart RestartR GET
|
||||
/log LogR GET
|
||||
|
||||
/config ConfigurationR GET
|
||||
/config/repository RepositoriesR GET
|
||||
|
|
|
@ -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
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -5,6 +5,7 @@ git-annex (3.20130115) UNRELEASED; urgency=low
|
|||
* webapp: Avoid an error if a transfer is stopped just as it finishes.
|
||||
Closes: #698184
|
||||
* webapp: Now always logs to .git/annex/daemon.log.
|
||||
* webapp: Now has a page to view the log, accessed from the control menu.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 14 Jan 2013 18:35:01 -0400
|
||||
|
||||
|
|
6
templates/control/log.hamlet
Normal file
6
templates/control/log.hamlet
Normal file
|
@ -0,0 +1,6 @@
|
|||
<div .span9 .hero-unit>
|
||||
<p>
|
||||
Here's everything that has been logged by the git-annex assistant, #
|
||||
as well as by programs it has run.
|
||||
<pre>
|
||||
#{logcontent}
|
|
@ -8,3 +8,5 @@
|
|||
<i .icon-repeat></i> Restart daemon
|
||||
<a href="@{ShutdownR}">
|
||||
<i .icon-off></i> Shutdown daemon
|
||||
<a href="@{LogR}">
|
||||
<i .icon-list></i> View log
|
||||
|
|
Loading…
Reference in a new issue