mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-27 11:56:14 +08:00
Enable logging on Linux through MshLog
This commit is contained in:
parent
79ae396917
commit
39af334f9f
@ -134,54 +134,23 @@ namespace System.Management.Automation
|
||||
/// <returns></returns>
|
||||
private static Collection<LogProvider> CreateLogProvider(string shellId)
|
||||
{
|
||||
#if V2
|
||||
try
|
||||
{
|
||||
Assembly crimsonAssembly = Assembly.Load(_crimsonLogProviderAssemblyName);
|
||||
|
||||
if (crimsonAssembly != null)
|
||||
{
|
||||
LogProvider logProvider = (LogProvider)crimsonAssembly.CreateInstance(_crimsonLogProviderTypeName,
|
||||
false, // don't ignore case
|
||||
BindingFlags.CreateInstance,
|
||||
null, // use default binder
|
||||
null,
|
||||
null, // use current culture
|
||||
null // no special activation attributes
|
||||
);
|
||||
|
||||
System.Diagnostics.Debug.Assert(logProvider != null);
|
||||
return logProvider;
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
_trace.TraceException(e);
|
||||
}
|
||||
catch (BadImageFormatException e)
|
||||
{
|
||||
_trace.TraceException(e);
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
_trace.TraceException(e);
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
_trace.TraceException(e);
|
||||
}
|
||||
#endif
|
||||
Collection<LogProvider> providers = new Collection<LogProvider>();
|
||||
// Porting note: Linux does not support ETW
|
||||
#if !UNIX
|
||||
|
||||
try
|
||||
{
|
||||
#if !CORECLR //TODO:CORECLR EventLogLogProvider not handled yet
|
||||
LogProvider eventLogLogProvider = new EventLogLogProvider(shellId);
|
||||
providers.Add(eventLogLogProvider);
|
||||
#endif
|
||||
|
||||
#if UNIX
|
||||
LogProvider sysLogProvider = new PSSysLogProvider();
|
||||
providers.Add(sysLogProvider);
|
||||
#else
|
||||
LogProvider etwLogProvider = new PSEtwLogProvider();
|
||||
providers.Add(etwLogProvider);
|
||||
#endif
|
||||
|
||||
return providers;
|
||||
}
|
||||
@ -198,7 +167,7 @@ namespace System.Management.Automation
|
||||
// when running as non-admin user. In that case, we will default
|
||||
// to dummy log.
|
||||
}
|
||||
#endif
|
||||
|
||||
providers.Add(new DummyLogProvider());
|
||||
return providers;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace System.Management.Automation.Tracing
|
||||
/// Initializes a new instance of this class.
|
||||
/// </summary>
|
||||
/// <param name="applicationId">The log identity name used to identify the application in syslog.</param>
|
||||
/// <param name="level">The trace lavel to enable.</param>
|
||||
/// <param name="level">The trace level to enable.</param>
|
||||
/// <param name="keywords">The keywords to enable.</param>
|
||||
/// <param name="channels">The output channels to enable.</param>
|
||||
public SysLogProvider(string applicationId, PSLevel level, PSKeyword keywords, PSChannel channels)
|
||||
|
Loading…
Reference in New Issue
Block a user