Ejemplo n.º 1
0
        /// <summary>
        /// Make sure this log is registered.
        /// </summary>
        internal static void EnsureLoaded()
        {
            if (log != null)
                return;

            var status = (IVsStatusbar)VSUtilities.ServiceProvider().GetService(typeof (SVsStatusbar));

            var add = false;
            lock (logLock)
            {
                if (log == null)
                {
                    log = new StatusBarLog(status);
                    add = true;
                }
            }
            if (add)
            {
                AddAdditionalLogger(log);
                AddToContext(DContext.VSStatusBar, log);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Load a context from current user registry.
 /// </summary>
 public static LogContext LoadFromRegistry(DContext context, DLog[] defaultLoggers)
 {
     using (var key = Registry.CurrentUser.OpenSubKey(RegistryConstants.LOGGING))
     {
         if (key == null)
             return new LogContext(context, defaultLoggers);
         var valueName = ((int) context).ToString(CultureInfo.InvariantCulture);
         var value = key.GetValue(valueName) as string;
         if (value == null)
         {
             value = key.GetValue("") as string;
         }
         if (value == null)
             return new LogContext(context, defaultLoggers);
         return new LogContext(context, ParseLoggers(value));
     }                
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Unregister the given additional logger.
 /// </summary>
 public static void RemoveAdditionalLogger(DLog log)
 {
     DLog tmp;
     additionalLoggers.TryRemove(log, out tmp);
 }
Ejemplo n.º 4
0
 private LogContext(DContext context, DLog[] loggers)
 {
     Context = context;
     Loggers = ((loggers != null) && (loggers.Length > 0)) ? loggers : null;
 }
Ejemplo n.º 5
0
 protected static void AddToContext(DContext ctx, DLog log)
 {
     GetContext(ctx).AddLogger(log);
     additionalLoggers.TryAdd(log, log);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Register the given additional logger.
 /// </summary>
 public static void AddAdditionalLogger(DLog log)
 {
     additionalLoggers.TryAdd(log, log);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Unregister the given additional logger.
        /// </summary>
        public static void RemoveAdditionalLogger(DLog log)
        {
            DLog tmp;

            additionalLoggers.TryRemove(log, out tmp);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Register the given additional logger.
 /// </summary>
 public static void AddAdditionalLogger(DLog log)
 {
     additionalLoggers.TryAdd(log, log);
 }
Ejemplo n.º 9
0
 internal void AddLogger(DLog logger)
 {
     lock (this)
     {
         if (loggers == null)
             loggers = new List<DLog>();
         loggers.Add(logger);
     }
 }
Ejemplo n.º 10
0
 private LogContext(DContext context, DLog[] loggers)
 {
     Context = context;
     var dLogs = ((loggers != null) && (loggers.Length > 0)) ? loggers : null;
     if(dLogs != null)
         this.loggers = dLogs.ToList();
 }
Ejemplo n.º 11
0
 protected static void AddToContext(DContext ctx, DLog log)
 {
     GetContext(ctx).AddLogger(log);
     additionalLoggers.TryAdd(log, log);
 }