예제 #1
0
        /// <summary>
        /// Constructor. Registers the given log target with the provided threads
        /// for listening for log messages.
        /// </summary>
        /// <param name="target">The target that should receive events.</param>
        /// <param name="threads">The threads which the target will be registered
        /// with for event notifications.</param>
        public LogSession(ILogTarget target, params Thread[] threads)
        {
            Target  = target;
            Threads = threads.Distinct().ToArray();

            foreach (Thread thread in Threads)
            {
                if (!Logger.Listeners.ContainsKey(thread))
                {
                    Logger.Listeners.Add(thread, new LogThreadTargets());
                }
                Logger.Listeners[thread].Add(target);
            }

            Target.OnEventLogged(this, new LogEventArgs(
                                     new LogEntry(S._("Session started"), LogLevel.Information)));
        }