Example #1
0
        /// <summary>
        /// Create a log provider based on a shell Id.
        /// </summary>
        /// <param name="shellId"></param>
        /// <returns></returns>
        private static Collection <LogProvider> CreateLogProvider(string shellId)
        {
            Collection <LogProvider> providers = new Collection <LogProvider>();

            // Porting note: Linux does not support ETW

            try
            {
#if UNIX
                LogProvider sysLogProvider = new PSSysLogProvider();
                providers.Add(sysLogProvider);
#else
                LogProvider etwLogProvider = new PSEtwLogProvider();
                providers.Add(etwLogProvider);
#endif

                return(providers);
            }
            catch (ArgumentException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (SecurityException)
            {
                // This exception will happen if we try to create an event source
                // (corresponding to the current running minishell)
                // when running as non-admin user. In that case, we will default
                // to dummy log.
            }

            providers.Add(new DummyLogProvider());
            return(providers);
        }
Example #2
0
        private static Collection <LogProvider> CreateLogProvider(string shellId)
        {
            Collection <LogProvider> collection = new Collection <LogProvider>();

            try
            {
                LogProvider item = new EventLogLogProvider(shellId);
                collection.Add(item);
                item = new PSEtwLogProvider();
                collection.Add(item);
                return(collection);
            }
            catch (ArgumentException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (SecurityException)
            {
            }
            collection.Add(new DummyLogProvider());
            return(collection);
        }
Example #3
0
        /// <summary>
        /// Create a log provider based on a shell Id.
        /// </summary>
        /// <param name="shellId"></param>
        /// <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
                LogProvider etwLogProvider = new PSEtwLogProvider();
                providers.Add(etwLogProvider);

                return(providers);
            }
            catch (ArgumentException)
            {
            }
            catch (InvalidOperationException)
            {
            }
            catch (SecurityException)
            {
                // This exception will happen if we try to create an event source
                // (corresponding to the current running minishell)
                // when running as non-admin user. In that case, we will default
                // to dummy log.
            }
#endif
            providers.Add(new DummyLogProvider());
            return(providers);
        }