Skip to content

833 Allow log level to be set in debug mode.#872

Merged
adamralph merged 2 commits into
scriptcs:devfrom
jamiehumphries:833-debug-log-level
Dec 16, 2014
Merged

833 Allow log level to be set in debug mode.#872
adamralph merged 2 commits into
scriptcs:devfrom
jamiehumphries:833-debug-log-level

Conversation

@jamiehumphries
Copy link
Copy Markdown
Contributor

Fixes #833 by allowing any log level to be set in debug mode. If this is accepted then it makes #871 obsolete.

@Romoku, do you want to see if this does what you hope it will? You should run with -D -loglevel info or error if you do not want to see all of the debug output.

@adamralph adamralph self-assigned this Dec 16, 2014
@adamralph
Copy link
Copy Markdown
Contributor

Thanks @jamiehumphries. I think this is a much better solution!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a replication of the logic in ArgumentHandler? I.e. the resolution of the log level and debug switch should already have been done by the time this code is run, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but I left this here for a couple of reasons:

  1. I had to do something to convert from a nullable LogLevel? to a non-null LogLevel so that it could be passed as a parameter below. Just doing commandArgs.LogLevel.Value felt a bit wrong and also gave a Possible 'System.InvalidOperationException' warning.
  2. Since this method and class are public, it didn't feel right to assume that it would only ever be called with args that have been sanitized in ArgumentHandler.

I also considered only doing the logic here and not in ArgumentHandler, but again that felt wrong because the ArgumentHandler should output the args in their expected final form.

The only other option that I could think of was having two classes along the lines of PreParsingScriptCsArgs and ParsedScriptCsArgs (with better names!) which had a LogLevel? and a LogLevel respectively, but I felt that may have been overkill!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair points. How about a compromise: this line simply defaults to info level when null, but the resolution of log level and debug switch is left in ArgumentHandler where it belongs? I just want to avoid the duplication.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep fine. I'll change that and put it back up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done now.

@jamiehumphries
Copy link
Copy Markdown
Contributor Author

@adamralph, yeah I agree that this is better. The slight benifit to #871 (the reason I did it that way to begin with) is that it makes no changes at all to the public interface of the library, whereas this turns a public LogLevel into a LogLevel?. But overall I prefer the end result of this option and I have checked that everything within the code uses the LogLevel? safely.

@adamralph
Copy link
Copy Markdown
Contributor

Awesome, thanks!

adamralph added a commit that referenced this pull request Dec 16, 2014
833 Allow log level to be set in debug mode.
@adamralph adamralph merged commit 8fef65d into scriptcs:dev Dec 16, 2014
@adamralph
Copy link
Copy Markdown
Contributor

@jamiehumphries you've been added to https://github.com/scriptcs/scriptcs/wiki/Contributors 🏆

This will be part of the 0.12 release.

@jamiehumphries
Copy link
Copy Markdown
Contributor Author

Thanks @adamralph 😄

@jamiehumphries jamiehumphries deleted the 833-debug-log-level branch December 16, 2014 10:48
@khellang
Copy link
Copy Markdown
Member

This is nice! 😁👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot mix loglevel and debug command line args

3 participants