Reputation:
I would like to know a base thing.
_logger.LogInformation("Hi, Am I magic string?");
In the above line, does the string fall under magic string?
Any hardcoded validation/action against a response/return is considered a "magic string" to me. (Eg: _config["EmailTo"]
should be _config.EmailTo
, if(list.contains("error"))
should be if(list.contains(errorValue))
Appreciate your thoughts!
Upvotes: 1
Views: 268
Reputation: 50672
Magic exists when the audience expects one thing but sees another.
If there is any system that reads the log file and tries to interpret it and then take some action this string has become a contract/magic because changing it will confuse that system.
A good rule of thumb is to never parse logs unless there are well defined and guarded standards for the log. Parsing strings is not one of them in my opinion and experience. Error numbers are much better/safer.
Upvotes: 2