From 79332c2a3dfdb1209d0fa5b00593166a56a52dc1 Mon Sep 17 00:00:00 2001 From: Abhipsa Misra Date: Fri, 6 Aug 2021 13:43:59 -0700 Subject: [PATCH 1/4] refactor(tools-logs): Update log capture script to be configurable and use powershell --- tools/CaptureLogs/iot_startlog.cmd | 2 -- tools/CaptureLogs/iot_startlog.ps1 | 23 +++++++++++++++++++++++ tools/CaptureLogs/iot_stoplog.cmd | 2 -- tools/CaptureLogs/iot_stoplog.ps1 | 17 +++++++++++++++++ tools/CaptureLogs/readme.md | 22 ++++++++++++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) delete mode 100644 tools/CaptureLogs/iot_startlog.cmd create mode 100644 tools/CaptureLogs/iot_startlog.ps1 delete mode 100644 tools/CaptureLogs/iot_stoplog.cmd create mode 100644 tools/CaptureLogs/iot_stoplog.ps1 diff --git a/tools/CaptureLogs/iot_startlog.cmd b/tools/CaptureLogs/iot_startlog.cmd deleted file mode 100644 index 0b79c8a8be..0000000000 --- a/tools/CaptureLogs/iot_startlog.cmd +++ /dev/null @@ -1,2 +0,0 @@ -logman create trace IotTrace -o iot.etl -pf iot_providers.txt -logman start IotTrace diff --git a/tools/CaptureLogs/iot_startlog.ps1 b/tools/CaptureLogs/iot_startlog.ps1 new file mode 100644 index 0000000000..61b921c674 --- /dev/null +++ b/tools/CaptureLogs/iot_startlog.ps1 @@ -0,0 +1,23 @@ +param( + [Parameter(Mandatory)] + [string] $TraceName, + + [Parameter(Mandatory)] + [string] $Output, + + [Parameter(Mandatory)] + [string] $ProviderFile +) + +Function StartLogCapture() +{ + $createTrace = "logman create trace $TraceName -o $Output -pf $ProviderFile" + Write-Host "Invoking: $createTrace." + Invoke-Expression $createTrace + + $startTrace = "logman start $TraceName" + Write-Host "Invoking: $startTrace." + Invoke-Expression $startTrace +} + +StartLogCapture \ No newline at end of file diff --git a/tools/CaptureLogs/iot_stoplog.cmd b/tools/CaptureLogs/iot_stoplog.cmd deleted file mode 100644 index a3e91642cc..0000000000 --- a/tools/CaptureLogs/iot_stoplog.cmd +++ /dev/null @@ -1,2 +0,0 @@ -logman stop IotTrace -logman delete IotTrace diff --git a/tools/CaptureLogs/iot_stoplog.ps1 b/tools/CaptureLogs/iot_stoplog.ps1 new file mode 100644 index 0000000000..eb4db74ebd --- /dev/null +++ b/tools/CaptureLogs/iot_stoplog.ps1 @@ -0,0 +1,17 @@ +param( + [Parameter(Mandatory)] + [string] $TraceName +) + +Function StopLogCapture() +{ + $stopTrace = "logman stop $TraceName" + Write-Host "Invoking: $stopTrace." + Invoke-Expression $stopTrace + + $deleteTrace = "logman delete $TraceName" + Write-Host "Invoking: $deleteTrace." + Invoke-Expression $deleteTrace +} + +StopLogCapture \ No newline at end of file diff --git a/tools/CaptureLogs/readme.md b/tools/CaptureLogs/readme.md index 66fdf0b588..9faad3db93 100644 --- a/tools/CaptureLogs/readme.md +++ b/tools/CaptureLogs/readme.md @@ -1,5 +1,27 @@ # Capturing Traces +1. Launch Powershell with administrator priviledges. +2. To start capturing traces, invoke `iot_startlog.ps1`. + 1. Pass in the following required parameters: + 1. `-TraceName` - the name of the event trace data collector. + 2. `-Output` - the output log file that will be created. This should be a `.etl` file. + 3. `-ProviderFile` - The file listing multiple Event Trace providers to enable. The file should be a text file containing one provider per line. + The Azure IoT SDK providers file is present [here](https://github.com/Azure/azure-iot-sdk-csharp/blob/master/tools/CaptureLogs/iot_providers.txt). The providers list with their corresponding package details are present [here](https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/CaptureLogs#azure-iot-sdk-providers). + + Sample usage: + ```powersehll + .\iot_startlog.ps1 -Output iot.etl -ProviderFile .\iot_providers.txt -TraceName IotTrace + ``` + +3. To stop capturing traces, invoke `iot_stoplog.ps1`. + 1. Pass in the following required parameter: + 1. `-TraceName` - the name of the event trace data collector. Same as the one used while starting trace capture. + + Sample usage: + ```powersehll + .\iot_stoplog.ps1 -TraceName IotTrace + ``` + ## Windows On Windows logman or PerfView can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/windows-instructions.md#traces From 9d21c780674367d109fac03e5c830f87472638c8 Mon Sep 17 00:00:00 2001 From: Abhipsa Misra Date: Fri, 6 Aug 2021 13:56:23 -0700 Subject: [PATCH 2/4] reorder --- tools/CaptureLogs/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/CaptureLogs/readme.md b/tools/CaptureLogs/readme.md index 9faad3db93..55a0ab7216 100644 --- a/tools/CaptureLogs/readme.md +++ b/tools/CaptureLogs/readme.md @@ -1,5 +1,8 @@ # Capturing Traces +## Windows +On Windows logman or PerfView can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/windows-instructions.md#traces + 1. Launch Powershell with administrator priviledges. 2. To start capturing traces, invoke `iot_startlog.ps1`. 1. Pass in the following required parameters: @@ -22,9 +25,6 @@ .\iot_stoplog.ps1 -TraceName IotTrace ``` -## Windows -On Windows logman or PerfView can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/windows-instructions.md#traces - ## Linux On Linux and OSX LTTNG and perfcollect can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/project/linux-performance-tracing.md From 77fc2f741d962bcd556b1d0fa0b7d6b8f3c1c640 Mon Sep 17 00:00:00 2001 From: Abhipsa Misra Date: Fri, 6 Aug 2021 14:01:54 -0700 Subject: [PATCH 3/4] minor --- tools/CaptureLogs/readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/CaptureLogs/readme.md b/tools/CaptureLogs/readme.md index 55a0ab7216..3d6cf1402a 100644 --- a/tools/CaptureLogs/readme.md +++ b/tools/CaptureLogs/readme.md @@ -3,6 +3,8 @@ ## Windows On Windows logman or PerfView can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/windows-instructions.md#traces +We have provided the following convinience scripts for log collection using `logman`. + 1. Launch Powershell with administrator priviledges. 2. To start capturing traces, invoke `iot_startlog.ps1`. 1. Pass in the following required parameters: From ba5e041137930e470bcc3637c4d2aed21aa7b383 Mon Sep 17 00:00:00 2001 From: Abhipsa Misra Date: Fri, 6 Aug 2021 14:03:34 -0700 Subject: [PATCH 4/4] spelling!!! --- tools/CaptureLogs/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/CaptureLogs/readme.md b/tools/CaptureLogs/readme.md index 3d6cf1402a..1dc589c93b 100644 --- a/tools/CaptureLogs/readme.md +++ b/tools/CaptureLogs/readme.md @@ -3,9 +3,9 @@ ## Windows On Windows logman or PerfView can be used to collect traces. For more information please see https://github.com/dotnet/runtime/blob/master/docs/workflow/debugging/libraries/windows-instructions.md#traces -We have provided the following convinience scripts for log collection using `logman`. +We have provided the following convenience scripts for log collection using `logman`. -1. Launch Powershell with administrator priviledges. +1. Launch Powershell with administrator privileges. 2. To start capturing traces, invoke `iot_startlog.ps1`. 1. Pass in the following required parameters: 1. `-TraceName` - the name of the event trace data collector.