You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some codebases will have embraced TaskEither and friends but will not have adopted a hard-line stance against impure logging.
In these codebases, imperative logging is tolerated. Fine you might say, but it does open us up to the antipattern of premature logging -- logging that happens during program construction when it should actually happen during program execution.
Here's an example:
constlaunch=(numberToLaunch: number): TaskEither<never,string>=>{// This logging is premature. This is the line that would be flagged by the proposed rule.// The author believed they were logging during program execution but they are actually logging during program construction.console.info(`Launching ${numberToLaunch} nukes!`);// TE.of is just for illustration here. It could be an HTTP call or any other impure operation// and the effect type doesn't have to be TE (it could be IO, RTE, etc).returnTE.of(`${numberToLaunch} nukes launched`);};// This returns an effect but doesn't interpret (execute) it.constlaunchSevenNukes=launch(7);// At this point, the logs say "Launching 7 nukes" but no such operation has actually started!// It is only after we interpret the effect that the actual nuke launching operation has started.constlaunchNukesPromise=launchSevenNukes();// Here is the first moment we should actually see logs.// And here is the actual result of launching.constresult=awaitlaunchNukesPromise;
If we construct the effect and then:
defer execution to much later in the program
decide not to actually execute it
execute it multiple times (e.g. to implement retries)
... then the logs are going to be misleading to one degree or another.
The text was updated successfully, but these errors were encountered:
Some codebases will have embraced TaskEither and friends but will not have adopted a hard-line stance against impure logging.
In these codebases, imperative logging is tolerated. Fine you might say, but it does open us up to the antipattern of premature logging -- logging that happens during program construction when it should actually happen during program execution.
Here's an example:
If we construct the effect and then:
... then the logs are going to be misleading to one degree or another.
The text was updated successfully, but these errors were encountered: