-
Notifications
You must be signed in to change notification settings - Fork 4.1k
AzureRT S54 PR #2 - Record Debug Messages & Fix Add-AzureVhd #905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9c465b4
Merge pull request #84 from Azure/release-0.9.8
huangpf 56d8303
throw AggregateException in case of exceptions in Add-AzureVhd
huangpf cbe36d2
Truncate extension id string if too long
huangpf 2026031
Merge branch 'release-0.9.8' of https://github.com/Azure/azure-powers…
huangpf c0a2938
Fix #387
huangpf 4c1be82
Merge pull request #85 from Azure/dev
huangpf 7431ee7
RecordDebugMessages
huangpf a14b114
Merge pull request #86 from Azure/dev
huangpf d7a961c
Merge pull request #87 from Azure/dev
huangpf 8038643
Merge branch 'dev' of https://github.com/huangpf/azure-powershell int…
huangpf d8f76ce
update
huangpf ef66d68
update
huangpf d4d5923
update
huangpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| using Newtonsoft.Json; | ||
| using System.IO; | ||
| using System.Management.Automation.Host; | ||
| using System.Text; | ||
| using System.Threading; | ||
|
|
||
| namespace Microsoft.WindowsAzure.Commands.Utilities.Common | ||
|
|
@@ -39,6 +40,8 @@ public abstract class AzurePSCmdlet : PSCmdlet, IDisposable | |
|
|
||
| private DebugStreamTraceListener _adalListener; | ||
| protected static AzurePSDataCollectionProfile _dataCollectionProfile = null; | ||
| protected static string _errorRecordFolderPath = null; | ||
| protected const string _fileTimeStampSuffixFormat = "yyyy-MM-dd-THH-mm-ss-fff"; | ||
|
|
||
| protected AzurePSQoSEvent QosEvent; | ||
|
|
||
|
|
@@ -254,7 +257,7 @@ protected bool IsVerbose() | |
|
|
||
| protected new void WriteError(ErrorRecord errorRecord) | ||
| { | ||
| FlushDebugMessages(); | ||
| FlushDebugMessages(IsDataCollectionAllowed()); | ||
| if (QosEvent != null && errorRecord != null) | ||
| { | ||
| QosEvent.Exception = errorRecord.Exception; | ||
|
|
@@ -362,8 +365,13 @@ protected void SafeWriteOutputPSObject(string typeName, params object[] args) | |
| WriteObject(customObject); | ||
| } | ||
|
|
||
| private void FlushDebugMessages() | ||
| private void FlushDebugMessages(bool record = false) | ||
| { | ||
| if (record) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (IsDataCollectionAllowed())
{
RecordDebugMessages();
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same above |
||
| { | ||
| RecordDebugMessages(); | ||
| } | ||
|
|
||
| string message; | ||
| while (_debugMessages.TryDequeue(out message)) | ||
| { | ||
|
|
@@ -373,6 +381,43 @@ private void FlushDebugMessages() | |
|
|
||
| protected abstract void InitializeQosEvent(); | ||
|
|
||
| private void RecordDebugMessages() | ||
| { | ||
| // Create 'ErrorRecords' folder under profile directory, if not exists | ||
| if (string.IsNullOrEmpty(_errorRecordFolderPath) || !Directory.Exists(_errorRecordFolderPath)) | ||
| { | ||
| _errorRecordFolderPath = Path.Combine(AzureSession.ProfileDirectory, "ErrorRecords"); | ||
| Directory.CreateDirectory(_errorRecordFolderPath); | ||
| } | ||
|
|
||
| CommandInfo cmd = this.MyInvocation.MyCommand; | ||
|
|
||
| string filePrefix = cmd.Name; | ||
| string timeSampSuffix = DateTime.Now.ToString(_fileTimeStampSuffixFormat); | ||
| string fileName = filePrefix + "_" + timeSampSuffix + ".log"; | ||
| string filePath = Path.Combine(_errorRecordFolderPath, fileName); | ||
|
|
||
| StringBuilder sb = new StringBuilder(); | ||
| sb.Append("Module : ").AppendLine(cmd.ModuleName); | ||
| sb.Append("Cmdlet : ").AppendLine(cmd.Name); | ||
|
|
||
| sb.AppendLine("Parameters"); | ||
| foreach (var item in this.MyInvocation.BoundParameters) | ||
| { | ||
| sb.Append(" -").Append(item.Key).Append(" : "); | ||
| sb.AppendLine(item.Value == null ? "null" : item.Value.ToString()); | ||
| } | ||
|
|
||
| sb.AppendLine(); | ||
|
|
||
| foreach (var content in _debugMessages) | ||
| { | ||
| sb.AppendLine(content); | ||
| } | ||
|
|
||
| AzureSession.DataStore.WriteFile(filePath, sb.ToString()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Invoke this method when the cmdlet is completed or terminated. | ||
| /// </summary> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Common/Commands.ScenarioTest/Resources/ServiceManagement/Files/LongRoleName.Cloud.cscfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- | ||
| ********************************************************************************************** | ||
|
|
||
| This file was generated by a tool from the project file: ServiceConfiguration.Cloud.cscfg | ||
|
|
||
| Changes to this file may cause incorrect behavior and will be lost if the file is regenerated. | ||
|
|
||
| ********************************************************************************************** | ||
| --> | ||
| <ServiceConfiguration serviceName="AzureCloudService2" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6"> | ||
| <Role name="WebRole1"> | ||
| <Instances count="1" /> | ||
| <ConfigurationSettings> | ||
| <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> | ||
| </ConfigurationSettings> | ||
| </Role> | ||
| <Role name="Microsoft.Contoso.Department.ProjectCodeName.Worker"> | ||
| <Instances count="1" /> | ||
| <ConfigurationSettings> | ||
| <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> | ||
| </ConfigurationSettings> | ||
| </Role> | ||
| </ServiceConfiguration> |
Binary file added
BIN
+17.6 MB
src/Common/Commands.ScenarioTest/Resources/ServiceManagement/Files/LongRoleName.Cloud.cspkg
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,796 changes: 854 additions & 942 deletions
1,796
...ommands.ScenarioTest.ServiceManagementTests/RunServiceDeploymentExtensionCmdletTests.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass
IsDataCollectionAllowed()just use it inFlushDebugMessagesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we only want to log when there is an exception. Do you mean you want to log everything if data collection is allowed?