And wanted to switch that runStderrLoggingT call to runNoLoggingT when env == Production. But the fact that runStderrLoggingT :: LoggingT m a -> m a & runNoLoggingT :: NoLoggingT m a -> m a is throwing me off :confused:
A richer Environment type might also be nicer to manage. When I see lots of case statements on the same thing, it makes me want to lift those into the type itself
Yeah I was thinking of at least having the library define functions like getHttpLogger : Environment -> ..., getSqlLogger :: Environment -> ..., etc instead of having all those case statements in the exe's Main.
Today was prod launch day so maybe I'll actually get to do some code-quality refactoring instead of "the requirements have changed!"-refactoring soon :P
Is it possible to switch between
runNoLoggingT
&runStderrLoggingT
based on some variable?I have somthing like this:
And wanted to switch that
runStderrLoggingT
call torunNoLoggingT
whenenv == Production
. But the fact thatrunStderrLoggingT :: LoggingT m a -> m a
&runNoLoggingT :: NoLoggingT m a -> m a
is throwing me off :confused:Something like this? https://github.com/jamesdabbs/pi-base-2/blob/2323fe34a5f99f5db2cd47444fec3621882d4601/src/Config.hs#L32
Though just an
if
would suffice if you've only got two envsIt sounds like you may need to write your application code against a MonadLogger constraint rather than a concrete LoggingT type?
(wild arsed guess. Probably wrong. :slight_smile:)
@Jack Henahan @Ben Kolera Yerp, that's what I pretty much ended up doing:
https://github.com/Southern-Exposure-Seed-Exchange/southernexposure.com/blob/8cd14fa89905c7b6d5fc8e266c89aed38277791f/server/app/Main.hs#L77-L88
Was hoping I could just select between
runStderrLoggingT
orrunNoLoggingT
in thecase env of ...
but that seems OK enough...or something like that oughta work
Nope :frown: That was my first try but there's no
MonadLogger
constraint in either of thoseA richer
Environment
type might also be nicer to manage. When I see lots ofcase
statements on the same thing, it makes me want to lift those into the type itselfAnd then you can start carrying that around in a
Reader
or something and not have to refer to it explicitlyYeah I was thinking of at least having the library define functions like
getHttpLogger : Environment -> ...
,getSqlLogger :: Environment -> ...
, etc instead of having all those case statements in the exe'sMain
.But most of that is only used in main so it hasn't been worth refactoring considering the time crunch I've been in ;)
There's only 2
case env of
s in the actual appFair. :slight_smile: I'm just trying to dump thoughts out so I can get to sleep, so I'm probably babbling
Today was prod launch day so maybe I'll actually get to do some code-quality refactoring instead of "the requirements have changed!"-refactoring soon :P
All good! Don't let me keep you up :sleeping: