imazen / imageflow-dotnet-server

A super-fast image server to speed up your site - deploy as a microservice, serverless, or embeddable.
https://docs.imageflow.io
GNU Affero General Public License v3.0
252 stars 33 forks source link

Logging Issue #17

Closed gerneio closed 3 years ago

gerneio commented 4 years ago

Small issue, one I wasn't aware of until just now, but the ILogger format strings are not being used properly.

According to this SO post:

Microsoft.Extensions.Logging uses structured logging. This means that the placeholders are not numbers which refer to the different args passed, but are instead names which are associated with each of the args.

Here are the official docs on this LogTrace method: LINK

One of the places I noticed this at was within the CleanupWorker.DoTask method, but Looks like you are using the position reference format across all instances where you are logging info. Looks like if you at least keep the order of parameters sequential as compared to how you use them in the string, then it'll work just fine.

gerneio commented 4 years ago

Example of invalid Log statement:

logger?.LogTrace("{2}ms: Executing task {0} {1} ({3} tasks remaining)", item.Task.ToString(), item.RelativePath, sw.ElapsedMilliseconds.ToString(NumberFormatInfo.InvariantInfo).PadLeft(4), queue.Count.ToString(NumberFormatInfo.InvariantInfo));

lilith commented 4 years ago

Thanks for reporting this!