Log-Entry
Log-Entry copied to clipboard
Add switch and toggle to log code line number
Hi. This is not an issue but a feature request. Hoping to get a switch -linenumber [alias -line] to optionally add the line number to the log. Also, a global toggle to turn logging of line numbers on by default.
Thanks so much for making the effort to write and also publish this amazing tool. I'll try to add this feature myself when I have some time. I can tell you must have put so much time into it, ironing out all the bugs and weird edge cases. I did the same myself with Batch logging back in the day and never had the heart to convert it to powershell so yours is perfect.
Getting the line number is done like this:
$MyInvocation.ScriptLineNumber
I would use the feature like this:
Log -line "hi"
Result in the logfile should be: 17:52:08.42 Line176 hi
Just for reference, I am supporting this in https://github.com/geberit/elastic-helpers/blob/master/logging_examples/logging.ps1
Thank you for your suggestion. I will take this in consideration.
Thank you for your suggestion. I will take this in consideration.
Hi iRon7, I've added the functionality in my fork, and tested as a psm1 module and also in my own code, all seems good. I've created a pull request for you to add if you feel like. I am new to git, and github so apologies if I've breached etiquette or made any mistakes with this pull request.
Just for reference, I am supporting this in https://github.com/geberit/elastic-helpers/blob/master/logging_examples/logging.ps1
Thanks, I'll take a look.