You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PowerCommands Design Principles.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -40,11 +40,13 @@ As the name of the PowerCommand class is used as an identifier, their name must
40
40
### Store secrets outside the application path
41
41
PowerCommands handles export and imports of environment variables using YAML files it is the preferred way to store secrets. Dont store sensitive information inside the application path as it will be to easy to steal with a simple copy and paste operation.
42
42
43
-
# EXCEPTIONS HANDLING AND LOGGING
43
+
# EXCEPTIONS HANDLING, DIAGNOSTIC AND LOGGING
44
44
## Reduce coad bloat by avoiding try and catch
45
45
No need for try catch in PowerCommands Run method as the call already is encapsulated in a try catch block, to reduce coad bload let custom code just crasch and handle that by the PowerCommands runtime, it will be logged, it will be presented for the user in a generic way that not reveal sensitive informaiton that could be the case if you just use Console.WriteLine(ex.Message).
46
46
## Reduce coad bloat by avoiding logging
47
47
The runtime always logg information about the input and output from a PowerCommand execution, if you want to pass information from the PowerCommand to the log, you could use Output to to that.
48
+
## Use Diagnostic to display information to user
49
+
The Diagnostic service has the purpose to print out messages so use that rather then use Console.WriteLine, that way you can controll just how this messages should be handled. You could easaly swap or extend the standard Diagnostic service component. The Diagnostic service also has the funtionallity to time a method call and display it to the user.
Copy file name to clipboardExpand all lines: src/PainKiller.PowerCommands/PainKiller.PowerCommands.Bootstrap/Extensions/ServiceConfigurationExtensions.cs
_services.Logger.LogInformation($"Command {runResult.ExecutingCommand?.Identifier} run with input: [{runResult.Input.Raw}] output: [{runResult.Output}] status: [{runResult.Status}]");
SecurityConfiguration1=ConfigurationManager.GetAppDataConfiguration(newSecurityConfiguration{Encryption=newEncryptionConfiguration{SharedSecretEnvironmentKey=nameof(IEncryptionManager),SharedSecretSalt="-- salt --"}},ConfigurationConstants.SecurityFileName).Configuration;
Copy file name to clipboardExpand all lines: src/PainKiller.PowerCommands/PainKiller.PowerCommands.MyExampleCommands/Configuration/PowerCommandsConfiguration.cs
0 commit comments