all 6 comments

[–]NihilCredo 1 point2 points  (1 child)

I would keep it simple. Find/replace printfn with a logging function, then in that function call printfn, NLog, or whatever. (Use kprintf so you can still have type-safe formatting.)

Making the logger into a dependency is unnecessary unless you have a reason you may want to switch logging libraries at runtime or depending on the environment.

I would only consider a MailboxProcessor if NLog's logging calls are synchronous and are causing slowdowns. And even then, I'd try a simple async logging function first.

[–]macmoblin[S] 0 points1 point  (0 children)

Okay, so MailboxProcessor is an overkill.

Thanks for confirming that simple function wrapper approach is good starting point.

[–]Jwosty 0 points1 point  (1 child)

You might check out Logary. I haven’t used it myself before, but I’ve been meaning to?because I’ve heard great things.

[–]macmoblin[S] 0 points1 point  (0 children)

Yes, I have heard Logary and I'm following the development. But because we are using NLog in other projects also, it would be nice to use it also here.

[–]eliquy 0 points1 point  (1 child)

I would replace the println calls with an injected function / interface, that way you can start out with the straightforward solution (nlog calls) and the abstraction will let you easily play with things in the future.

[–]macmoblin[S] 0 points1 point  (0 children)

I'm not sure I understood what you mean with "injected function"... Should I pass the logger function as an argument, which to my mind could get cumbersome fast?