/// <summary>
 /// Add a destination to this logger. An attempt to add a destination twice will be ignored.
 /// </summary>
 /// <param name="destination">The destination to add.</param>
 public void AddDestination(ILogDestination destination)
 {
     lock (synchronizationLock)
     {
         destinations.Add(destination);
     }
 }
Example #2
0
        public void RemoveLogDestination(ILogDestination logDestination)
        {
            if (logDestination != null)
            {
                if (logDestination.IsRunning)
                {
                    logDestination.Stop();
                }

                lock (_destinations)
                {
                    var index = _destinations.FindIndex(d => d.Id == logDestination.Id);

                    if (index > -1)
                    {
                        _destinations.RemoveAt(index);
                    }
                    else
                    {
                        Log(string.Format("Unable to remove LogDestination, cannot find destination with an id of \"{0}\".", logDestination.Id), LogMessageSeverity.Warning);
                    }
                }
            }
            else
            {
                Log("Cannot remove Null LogDestination...", LogMessageSeverity.Error);
            }
        }
 /// <summary>
 /// Remove a destination from this logger.
 /// </summary>
 /// <param name="destination">The destination to remove.</param>
 public void RemoveDestination(ILogDestination destination)
 {
     lock (synchronizationLock)
     {
         destinations.Remove(destination);
     }
 }
 /// <summary>
 /// Returns whether this logger is logging to the given destination.
 /// </summary>
 /// <param name="destination">The destination.</param>
 /// <returns>Whether this logger is logging to the given destination.</returns>
 public bool ContainsDestination(ILogDestination destination)
 {
     lock (synchronizationLock)
     {
         return(destinations.Contains(destination));
     }
 }
Example #5
0
 public Processor(ILogSource source, ILogDestination destination, int maxBatchToProcess, IEnumerable <ISanitizer> sanitizerList, ILogger <Processor> logger)
 {
     _source            = source ?? throw new ArgumentNullException(nameof(source));
     _destination       = destination ?? throw new ArgumentNullException(nameof(destination));
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _sanitizerList     = sanitizerList ?? throw new ArgumentNullException(nameof(sanitizerList));
     _maxBatchToProcess = maxBatchToProcess;
 }
        /// <summary>
        /// Adds the target to the list.
        /// </summary>
        /// <param name="target">The log target.</param>
        /// <param name="loglevel">The minimum log level to consider</param>
        /// <param name="filter">The log filter.</param>
        public void AddTarget(ILogDestination target, LogMessageType loglevel, Library.Utility.IFilter filter)
        {
            if (target == null)
            {
                return;
            }

            m_targets.Add(new Tuple <ILogDestination, LogMessageType, Library.Utility.IFilter>(target, loglevel, filter ?? new Library.Utility.FilterExpression()));
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Duplicati.Library.Logging.LogWrapper"/> class.
        /// </summary>
        /// <param name="self">The log instance to wrap.</param>
        /// <param name="filter">The log filter to use</param>
        public LogScope(ILogDestination self, ILogFilter filter, LogScope parent)
        {
            Parent = parent;

            m_log    = self;
            m_filter = filter;

            if (parent != null)
            {
                Logging.Log.StartScope(this);
            }
        }
Example #8
0
 public void Dispose()
 {
     if (m_serverfile != null)
     {
         var sf = m_serverfile;
         m_serverfile = null;
         if (sf is IDisposable)
         {
             ((IDisposable)sf).Dispose();
         }
     }
 }
Example #9
0
        public void SetServerFile(string path, LogMessageType level)
        {
            var dir = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(path));

            if (!System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.CreateDirectory(dir);
            }

            m_serverfile     = new StreamLogDestination(path);
            m_serverloglevel = level;

            UpdateLogLevel();
        }
        public void Register()
        {
            if (_destination == null)
            {
                _destination = new RemoteLogViewerDestination(_callback);

                _logger.Log(string.Format("Registering RemoteLogViewerDestination with id \"{0}\".", _destination.Id));

                _logger.AddLogDestination(_destination);
            }
            else
            {
                throw new NotSupportedException("Client has already registered to view remote logs.");
            }
        }
        public void Unregister()
        {
            if (_destination != null)
            {
                _logger.Log(string.Format("Unregistering RemoteLogViewerDestination with id \"{0}\".", _destination.Id));

                _logger.RemoveLogDestination(_destination);

                _destination = null;
            }
            else
            {
                throw new NotSupportedException("Client has not registered to view remote logs.");
            }
        }
Example #12
0
        public void AddLogDestination(ILogDestination logDestination)
        {
            if (logDestination != null)
            {
                if (IsRunning)
                {
                    logDestination.Start();
                }

                lock (_destinations)
                {
                    _destinations.Add(logDestination);
                }
            }
            else
            {
                Log("Cannot add Null LogDestination...", LogMessageSeverity.Error);
            }
        }
Example #13
0
 public bool AddDestination(ILogDestination destination)
 {
     return(destinations.Add(destination));
 }
Example #14
0
 public bool RemoveDestination(ILogDestination destination)
 {
     return(destinations.Remove(destination));
 }
Example #15
0
 /// <summary>
 /// This method registers a destination to Logzy. The destination will be used
 /// to deliver created log lines.
 /// </summary>
 /// <param name="destination">An ILogDestination implementation.</param>
 /// <returns>The registered ILogDestination instance.</returns>
 public ILogDestination RegisterDestination(ILogDestination destination)
 {
     LogDestinations.Add(destination);
     return destination;
 }
Example #16
0
 /// <summary>
 /// Unregisters an ILogDestination instance from the list of destinations.
 /// </summary>
 /// <param name="destination"></param>
 public void UnregisterDestination(ILogDestination destination)
 {
     LogDestinations.Remove(destination);
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Duplicati.Library.Main.ControllerMultiLogTarget"/> class.
 /// </summary>
 /// <param name="target">The log target.</param>
 /// <param name="loglevel">The minimum log level to consider</param>
 /// <param name="filter">The log filter.</param>
 public ControllerMultiLogTarget(ILogDestination target, Logging.LogMessageType loglevel, Library.Utility.IFilter filter)
 {
     AddTarget(target, loglevel, filter);
 }
Example #18
0
 public void AddLogDestination(ILogDestination logDestination)
 {
     //ignore
 }
Example #19
0
 /// <summary>
 /// Starts a new scope, that can be stopped by disposing the returned instance
 /// </summary>
 /// <param name="log">The log target</param>
 /// <param name="level">The log level</param>
 /// <returns>The new scope.</returns>
 public static IDisposable StartScope(ILogDestination log, LogMessageType level)
 {
     return(StartScope(log, new LogTagFilter(level, null, null)));
 }
Example #20
0
 /// <summary>
 /// .ctor for the Collector
 /// </summary>
 /// <param name="source">The source of the Collector.</param>
 /// <param name="destination">The destination for the collector.</param>
 public Collector(ILogSource source, ILogDestination destination)
 {
     _source      = source;
     _destination = destination;
 }
Example #21
0
 /// <summary>
 /// .ctor for the Collector
 /// </summary>
 /// <param name="source">The source of the Collector.</param>
 /// <param name="destination">The destination for the collector.</param>
 /// <param name="logger">The logger.</param>
 public Collector(ILogSource source, ILogDestination destination, ILogger <Collector> logger)
 {
     _source      = source;
     _destination = destination;
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Example #22
0
 public ChinaStatsCollector(ILogSource source, ILogDestination destination) : base(source, destination)
 {
 }
Example #23
0
 /// <summary>
 /// Starts a new scope, that can be stopped by disposing the returned instance
 /// </summary>
 /// <param name="log">The log target</param>
 /// <param name="filter">The log filter</param>
 /// <returns>The new scope.</returns>
 public static IDisposable StartScope(ILogDestination log, ILogFilter filter = null, bool isolating = false)
 {
     return(new LogScope(log, filter, CurrentScope, isolating));
 }
Example #24
0
 public bool AddDestination(ILogDestination destination)
 {
     return destinations.Add(destination);
 }
Example #25
0
 /// <summary>
 /// Starts a new scope, that can be stopped by disposing the returned instance
 /// </summary>
 /// <param name="log">The log target</param>
 /// <param name="filter">The log filter</param>
 /// <returns>The new scope.</returns>
 public static IDisposable StartScope(ILogDestination log, ILogFilter filter = null)
 {
     return(new LogScope(log, filter, CurrentScope));
 }
Example #26
0
 public bool RemoveDestination(ILogDestination destination)
 {
     return destinations.Remove(destination);
 }
Example #27
0
 public void SetUp()
 {
     _mock           = new Mock <ILogDestination>();
     _logDestination = _mock.Object;
 }
Example #28
0
 public void RemoveLogDestination(ILogDestination logDestination)
 {
     //ignore
 }
 public ChinaStatsCollector(ILogSource source, ILogDestination destination, ILogger <ChinaStatsCollector> logger) : base(source, destination, logger)
 {
 }
 public Logger(LogLevel level, ILogDestination destination)
 {
     Destination = destination;
     Level       = level;
 }
 public void WriteMessage(string message, LogType logType, ILogDestination logDestination)
 {
     logDestination.WriteLog(message, logType, typesThatCanBeLogged());
 }