Turn On/Off logging

53 views
Skip to first unread message

jcm

unread,
Jun 6, 2013, 6:46:01 AM6/6/13
to yeso...@googlegroups.com
Hello,

I am trying  to understand how the new logging system works.

So I created a new site and slightly modified getHomeR 

getHomeR :: Handler RepHtml
getHomeR = do
    $(logError)  "Some message"

    (formWidget, formEnctype) <- generateFormPost sampleForm
    let submission = Nothing :: Maybe (FileInfo, Text)
        handlerName = "getHomeR" :: Text
    defaultLayout $ do
        aDomId <- newIdent
        setTitle "Welcome To Yesod!"
        $(widgetFile "homepage")

When I run yesod devel, I get the log message printed on stdout.
However when I cabal build and run the application, nothing is logged.

I played with shouldLog (Yesod typeclass), setting it to True but without any success. 

I guess the solution is simple (as always with Yesod) but I cannot see it...

Thank for your help

Regards

J-C

Anton Cheshkov

unread,
Jun 6, 2013, 7:01:01 AM6/6/13
to yeso...@googlegroups.com
Hello, 

i think the answer here:

Application.hs
...
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
makeApplication conf = do
    foundation <- makeFoundation conf

    -- Initialize the logging middleware
    logWare <- mkRequestLogger def
        { outputFormat =
            if development
                then Detailed True
                else Apache FromSocket
        , destination = Logger $ appLogger foundation
        }

    -- Create the WAI application and apply middlewares
    app <- toWaiAppPlain foundation
    return $ logWare app

--
You received this message because you are subscribed to the Google Groups "Yesod Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yesodweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Best regards,
Cheshkov Anton

jcm

unread,
Jun 6, 2013, 9:11:41 AM6/6/13
to yeso...@googlegroups.com
Hello Anton, 

Thank you for your idea but I think these lines specify the format only.

I forgot to mention it but I tried it also.

Regards

j-C

Felipe Almeida Lessa

unread,
Jun 6, 2013, 9:23:52 AM6/6/13
to yesodweb

Perhaps the problem is just buffering? On production it takes a certain amount of log messages in order to flush the log buffer.

--
Felipe.
Enviado do meu Nexus 4.

jcm

unread,
Jun 6, 2013, 10:54:42 AM6/6/13
to yeso...@googlegroups.com

Thank you Felipe, 

Ok but the logger is created with:

logger <- mkLogger True stdout

so according to the doc, the flush should happen after each loggerPut

Regards

J-C

Le jeudi 6 juin 2013 12:46:01 UTC+2, jcm a écrit :

Michael Snoyman

unread,
Jun 6, 2013, 6:44:36 PM6/6/13
to yeso...@googlegroups.com
Perhaps a silly question: are you certain that the call to logError ever happens? Try putting in an `error` call at the top of the function and running through the same steps, just to sanity check that the code is actually being recompiled.


jcm

unread,
Jun 10, 2013, 4:39:49 AM6/10/13
to yeso...@googlegroups.com
Hello Michael


Well... I was right on one point: the solution should be simple.

Peharps too many hours of programming made me loose the sense of simplicity...

Thank you

Regards

J-C

Le jeudi 6 juin 2013 12:46:01 UTC+2, jcm a écrit :
Reply all
Reply to author
Forward
0 new messages