-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Redirect ETW logging to Syslog on Linux #5144
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
Changes from 1 commit
479559d
ebfbdcf
536eb44
36c25c8
4e23d84
e8f138e
aff9e61
b529cba
ffb7a88
31f20e4
3db6101
1dfb014
731c5e1
c8372e8
9e4465a
c875f8d
99cf86d
89782f3
e20ca59
e7901fe
4e04118
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,19 +363,16 @@ internal override void SetDefaultSourcePath(string defaultPath) | |
| /// <returns> | ||
| /// The string identity to use for writing to syslog. | ||
| /// <para> | ||
| /// The default value is 'powershell' | ||
| /// The default value is 'powershell'. | ||
| /// </para> | ||
| /// </returns> | ||
| internal override string GetSysLogIdentity() | ||
| { | ||
| string fileName = Path.Combine(psHomeConfigDirectory, configFileName); | ||
| string identity = ReadValueFromFile<string>(fileName, "LogIdentity"); | ||
|
||
| if | ||
| ( | ||
| string.IsNullOrEmpty(identity) | ||
| || | ||
| StringComparer.OrdinalIgnoreCase.Compare(LogDefaultValueName, identity) == 0 | ||
| ) | ||
|
|
||
| if (string.IsNullOrEmpty(identity) || | ||
| identity.Equals(LogDefaultValue, StringComparer.OrdinalIgnoreCase)) | ||
| { | ||
| identity = "powershell"; | ||
|
||
| } | ||
|
|
@@ -387,20 +384,18 @@ internal override string GetSysLogIdentity() | |
| /// </summary> | ||
| /// <returns>One of the PSLevel values indicating the level to log. | ||
| /// <para> | ||
| /// The default value is PSLevel.Informational | ||
| /// The default value is PSLevel.Informational. | ||
| /// </para> | ||
| /// </returns> | ||
| internal override PSLevel GetLogLevel() | ||
| { | ||
| string fileName = Path.Combine(psHomeConfigDirectory, configFileName); | ||
| string levelName = ReadValueFromFile<string>(fileName, "LogLevel"); | ||
| PSLevel level; | ||
| if | ||
| ( | ||
| StringComparer.OrdinalIgnoreCase.Compare(LogDefaultValueName, levelName) == 0 | ||
| || | ||
| !Enum.TryParse<PSLevel>(levelName, true, out level ) | ||
| ) | ||
|
|
||
| if (string.IsNullOrEmpty(levelName) || | ||
| levelName.Equals(LogDefaultValue, StringComparer.OrdinalIgnoreCase) || | ||
| !Enum.TryParse<PSLevel>(levelName, true, out level)) | ||
| { | ||
| level = PSLevel.Informational; | ||
| } | ||
|
|
@@ -415,17 +410,17 @@ internal override PSLevel GetLogLevel() | |
| /// <summary> | ||
| /// Provides a string name to indicate the default for a configuration setting. | ||
| /// </summary> | ||
| const string LogDefaultValueName = "default"; | ||
| const string LogDefaultValue = "default"; | ||
|
|
||
| const PSChannel DefaultChannels = PSChannel.Operational; | ||
|
|
||
| /// <summary> | ||
| /// Gets the bitmask of the PSChannel values to log. | ||
| /// </summary> | ||
| /// <returns> | ||
| /// A bitmask of PSChannel.Operational and/or PSChannel.Analytic | ||
| /// A bitmask of PSChannel.Operational and/or PSChannel.Analytic. | ||
| /// <para> | ||
| /// The default value is PSChannel.Operational | ||
| /// The default value is PSChannel.Operational. | ||
| /// </para> | ||
| /// </returns> | ||
| internal override PSChannel GetLogChannels() | ||
|
|
@@ -440,7 +435,7 @@ internal override PSChannel GetLogChannels() | |
|
|
||
| foreach (string name in names) | ||
| { | ||
| if (StringComparer.OrdinalIgnoreCase.Compare(LogDefaultValueName, name) == 0) | ||
| if (name.Equals(LogDefaultValue, StringComparer.OrdinalIgnoreCase.Compare)) | ||
| { | ||
| result = 0; | ||
| break; | ||
|
|
@@ -462,7 +457,7 @@ internal override PSChannel GetLogChannels() | |
| return result; | ||
| } | ||
|
|
||
| // by default, do not include analytic events | ||
| // by default, do not include analytic events. | ||
| const PSKeyword DefaultKeywords = (PSKeyword) (0xFFFFFFFFFFFFFFFF & ~(ulong)PSKeyword.UseAlwaysAnalytic); | ||
|
|
||
| /// <summary> | ||
|
|
@@ -471,7 +466,7 @@ internal override PSChannel GetLogChannels() | |
| /// <returns> | ||
| /// A bitmask of PSKeyword values. | ||
| /// <para> | ||
| /// The default value is all keywords other than UseAlwaysAnalytic | ||
| /// The default value is all keywords other than UseAlwaysAnalytic. | ||
| /// </para> | ||
| /// </returns> | ||
| internal override PSKeyword GetLogKeywords() | ||
|
|
@@ -486,7 +481,7 @@ internal override PSKeyword GetLogKeywords() | |
|
|
||
| foreach (string name in names) | ||
| { | ||
| if (StringComparer.OrdinalIgnoreCase.Compare(LogDefaultValueName, name) == 0) | ||
| if (name.Equals(LogDefaultValue, StringComparer.OrdinalIgnoreCase)) | ||
| { | ||
| result = 0; | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| namespace System.Management.Automation.Tracing | ||
| { | ||
| /// <summary> | ||
| /// SysLog LogProvider implementation | ||
| /// SysLog LogProvider implementation. | ||
| /// </summary> | ||
| internal class PSSysLogProvider : LogProvider | ||
| { | ||
|
|
@@ -20,7 +20,7 @@ internal class PSSysLogProvider : LogProvider | |
| internal const PSKeyword DefaultKeywords = (PSKeyword) (0xFFFFFFFFFFFFFFFF & ~(ulong)PSKeyword.UseAlwaysAnalytic); | ||
|
||
|
|
||
| /// <summary> | ||
| /// Class constructor | ||
| /// Class constructor. | ||
| /// </summary> | ||
| static PSSysLogProvider() | ||
| { | ||
|
|
@@ -46,7 +46,7 @@ private static StringBuilder PayloadBuilder | |
| { | ||
| if (_payloadBuilder == null) | ||
| { | ||
| // First time initialization for this thread. | ||
| // NOTE: Thread static fields must be explicitly initialized for each thread. | ||
| _payloadBuilder = new StringBuilder(200); | ||
| } | ||
| return _payloadBuilder; | ||
|
|
||
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.
It looks like this same path creation is done repeatedly in other methods so it can be done just once in the constructor and assigned to a readonly field. Also psHomeConfigDirectory should be readonly since it is set just once in the constructor.
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.
The entire class uses this pattern and; while i was tempted to change it; I think it's beyond the scope of this PR. I will mark the two fields as read-only, though.
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.
Ok.
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.
I created issue #5179 to track this.