public PrefixedLogStrategy(ISHLogStrategy underlyingLogStrategy, string prefix)
        {
            if (underlyingLogStrategy == null)
            {
                throw new ArgumentNullException("underlyingLogStrategy");
            }

            m_underlyingLogStrategy = underlyingLogStrategy;
            m_prefix = prefix;
        }
        public PrefixedLogStrategy(ISHLogStrategy underlyingLogStrategy, string prefix)
        {
            if (underlyingLogStrategy == null)
            {
                throw new ArgumentNullException("underlyingLogStrategy");
            }

            m_underlyingLogStrategy = underlyingLogStrategy;
            m_prefix = prefix;
        }
    public static void Log(this ReflectionTypeLoadException ex, ISHLogStrategy log, string message)
    {
        var builder = new StringBuilder();
        builder.AppendLine(message);
        builder.AppendLine("ReflectionTypeLoadException: {0}".With(ex.Message));
        builder.AppendLine("    LoaderExceptions:".With(ex.Message));

        foreach (var l in ex.LoaderExceptions)
        {
            builder.AppendLine("        * {0}: {1}".With(l.GetType().Name, l.Message));
        }

        log.Error(builder.ToString());
    }
Esempio n. 4
0
    public static void Log(this ReflectionTypeLoadException ex, ISHLogStrategy log, string message)
    {
        var builder = new StringBuilder();

        builder.AppendLine(message);
        builder.AppendLine("ReflectionTypeLoadException: {0}".With(ex.Message));
        builder.AppendLine("    LoaderExceptions:".With(ex.Message));

        foreach (var l in ex.LoaderExceptions)
        {
            builder.AppendLine("        * {0}: {1}".With(l.GetType().Name, l.Message));
        }

        log.Error(builder.ToString());
    }
Esempio n. 5
0
 /// <summary>
 /// Construct the object.
 /// </summary>
 /// <param name="log">Log.</param>
 //[Inject]
 public void Construct(ISHLogStrategy log)
 {
     Log = log;
     m_controllerName = GetType().Name;
     Cloneable        = false;
 }
        private static void RaiseToEnabledSubscribers(MulticastDelegate handler, object sender, EventArgs e, ISHLogStrategy log)
        {
            if (handler != null)
            {
                var subscribers = handler.GetInvocationList();

                foreach (var s in subscribers)
                {
                    var eventSubscriber = s.Target as IEventSubscriber;

                    if (eventSubscriber != null && !eventSubscriber.enabled)
                    {
                        continue;
                    }

                    try
                    {
                        s.DynamicInvoke(sender, e);
                    }
                    catch (TargetInvocationException ex)
                    {
                        if (log == null)
                        {
                            throw ex.InnerException;
                        }
                        else
                        {
                            log.Debug("Error invoke event handler: {0}", ex.InnerException.Message);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Raise event and with a TargetInvocationException is catched it will not throw an exception, but it will log it and continue to next item on invocation list.
 /// </summary>
 /// <param name='handler'>
 /// Handler.
 /// </param>
 /// <param name='sender'>
 /// Sender.
 /// </param>
 public static void RaiseSafe <TEventArgs>(this EventHandler <TEventArgs> handler, object sender, TEventArgs e, ISHLogStrategy log)
     where TEventArgs : EventArgs
 {
     RaiseToEnabledSubscribers(handler, sender, e, log);
 }
 /// <summary>
 /// Raise event and with a TargetInvocationException is catched it will not throw an exception, but it will log it and continue to next item on invocation list.
 /// </summary>
 /// <param name='handler'>
 /// Handler.
 /// </param>
 /// <param name='sender'>
 /// Sender.
 /// </param>
 public static void RaiseSafe(this EventHandler handler, object sender, ISHLogStrategy log)
 {
     RaiseToEnabledSubscribers(handler, sender, EventArgs.Empty, log);
 }