-
Notifications
You must be signed in to change notification settings - Fork 74
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
Fast logger migration #274
Conversation
Rotated logs will now simply have `.1` `.2` ascending appended to the name of the base logs | ||
rather than be named after the date and time they were rotated at: | ||
`logs/keter/20230413_231415.log` -> `logs/keter/keter.log.1` | ||
Please update anything that depended on the old log naming and directory conventions accordingly. |
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.
how does this work with several apps?
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.
Noticed a typo here actually 🙏 Added some examples for app log changes just now.
I think deleting that log message datatype would be nice Line 59 in 1bd7e25
I've no idea why this was made typesafe, I hardly can imagine a situation you want to parse and re-use log messages. anyway, like I said you don't need an instance because you can use LoggingT: https://hackage.haskell.org/package/monad-logger-0.3.39/docs/Control-Monad-Logger.html#t:LoggingT fast logger provides you with x :: IO ()
x = runLoggingT (myFormatting fastlogHandle) $ $logInfo "messages from LogMessage as normal text"
myFormatting :: (LogStr -> IO ()) -> (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) |
Oh lol my eyes completely skipped over the unwrapper being exposed. Thanks for the heads up 👍 Though, I was considering my options and still think the best path forward would be to propagate a new |
import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask | ||
, withReaderT) | ||
|
||
-- | The top-level keter context monad, carrying around the main logger and some locally relevant configuration structure. |
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.
Please also refer to a relevant blogpost if you have one in mind for this design.
for example https://www.fpcomplete.com/blog/2017/06/readert-design-pattern/
this allows newer people to figure out what goes on with all the boilerplate :)
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.
I don't think I know of one off the top of my head more specialized than that, so if you don't mind I'll steal that link lol. Added
keter.cabal
Outdated
@@ -62,6 +62,9 @@ Library | |||
, attoparsec >= 0.10 | |||
, http-client >= 0.5.0 | |||
, http-conduit >= 2.1 | |||
, fast-logger | |||
, monad-logger | |||
, unliftio-core |
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.
I guess we should add upper bounds
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.
Done
src/Keter/AppManager.hs
Outdated
Terminate -> return noWorker | ||
|
||
launchWorker :: AppManager | ||
-> AppId | ||
-- | TODO: Propagate `KeterM` up through here? |
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.
this appears to be done already
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.
Done
src/Keter/Common.hs
Outdated
-- , show c | ||
-- ] | ||
-- loc <- fmap showLoc TH.qLocation | ||
-- [|(. ExceptionThrown (pack $(TH.lift loc)))|] |
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.
yeah, just delete it. we've git to conjure up past code, which rarely happens.
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.
Done
src/Keter/Main.hs
Outdated
e' <- | ||
case e of | ||
FSN.Removed fp _ _ -> do | ||
--log $ WatchedFile "removed" (fromFilePath fp) |
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.
shouldn't we re-add thes log lines as monad logger ones?
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.
Good catch! I used my fuzzy find plugin fearing this but I guess a few escaped my eyes
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.
oki, I'll merge this tonight, you may fixup whatever you want meanwhile. 🎉
thank you! |
This PR implements the changes discussed in #257 as well as some concerns discussed privately, namely:
rotate-logs
config option)systemd
, which automatically captures and tails stderr output.KeterM cfg a
monad to encapsulate a (logging + config) context, which crops up prominently.cfg
polymorphic!MonadLogger
-related capabilities via the internalLoggingT
representation.monad-logger
, giving us access toLoc
(module+line number) info at each call site.{keter|}$time|$module$:$line_num|$log_level> $msg
Where
{...}
signifies a part strictly only present when logging to stderr.{process-monitor> }$msg
and
{app-$name> }$msg
respectively. (Same
{...}
semantics as above)Keter.Conduit.Process.Unix
module. The extra info here is also not as useful as it is for internal logs. Perhaps in the future log formatting can be streamlined in a separate PR.LogMessage
ADT and its giganticShow
instance, which was a bit overkill and clunky for logging.logEx
utility.As was discussed privately, log rotation naming and directory scheme have had to be changed due to limitations in
fast-logger
. Namely, that it dictates the naming scheme of rotated logs with no straightforward way of customizing it to preserve backwards compatibility. On top of the public keter API changes due to theKeterM
refactor, package version has been bumped to2.1.0
to indicate a breaking change.Relevant parts of the test suite have also been rewritten to comply with the API changes, but overall semantics are still retained.
TODO:
-> Generalized logger creation in
Keter.Main
andKeter.App
toKeter.Logger.createLoggerViaConfig
-> Moved to
Keter.Logger
Investigate if we really still need a TVar for RotatingLog sincefast-logger
was implemented with the assumption of multithreaded contexts.Formatting