Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

New logger #120

Merged
merged 4 commits into from
Dec 4, 2015
Merged

New logger #120

merged 4 commits into from
Dec 4, 2015

Conversation

alanz
Copy link
Collaborator

@alanz alanz commented Dec 3, 2015

Updated logging to remove PCRE dependency

It now makes use of a blend of Control.Monad.Logger and Control.Logging,
in that it uses the monad logger log formatting functions, which
includes using TH for a location, and the Control.Logging IORef process,
so logging is available in any thread that has access to IO.

At the moment it has the same flushing behaviour as before.

Closes #112

cc @bergey

I now makes use of a blend of Control.Monad.Logger and Control.Logging,
in that it uses the monad logger log formatting functions, which
includes using TH for a location, and the Control.Logging IORef process,
so logging is available in any thread that has access to IO.

At the moment it has the same flushing behaviour as before.
, haskell-ide-engine
, hie-ghc-mod
, hie-hare
, hie-plugin-api
, hspec
, logging
, fast-logger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate of line 111?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

setLogTimeFormat :: String -> IO ()
setLogTimeFormat = atomicWriteIORef logTimeFormat

-- | This function, or 'withStderrLogging', must be wrapped around whatever
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While perhaps it's clear from the type, it might be good to mention in the docs that these modify global state. So, if you Control.Concurrent.Async.race (withStdoutLogging (logm "a")) (withFileLogging "log" (logm "b")), it's not deterministic which messages go to which logs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, because you should only ever run one of the withXXXLogging functions. Perhaps that should be documented to.

@mgsloan
Copy link
Collaborator

mgsloan commented Dec 4, 2015

LGTM!

I once did something similar, but it also associated the log info with threads (how to log, log level, etc). This lets you selectively log different portions of the process. There's certainly a case to be made that thread-local storage is inadvisable, but it certainly would be cool for things like this.

Lets keep it simple till we really find the need to do something more specialized.

alanz added a commit that referenced this pull request Dec 4, 2015
@alanz alanz merged commit 9d13bcb into haskell:master Dec 4, 2015
@alanz alanz deleted the new-logger branch April 23, 2017 12:48
@alanz alanz added this to the prehistory milestone Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants