コード例 #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Duplicati.Server.LogWriteHandler+LogEntry"/> struct.
            /// </summary>
            /// <param name="entry">The log entry to store</param>
            public LogEntry(Duplicati.Library.Logging.LogEntry entry)
            {
                this.ID        = System.Threading.Interlocked.Increment(ref _id);
                this.When      = entry.When;
                this.Message   = entry.FormattedMessage;
                this.Type      = entry.Level;
                this.Exception = entry.Exception;
                this.Tag       = entry.Tag;
                this.MessageID = entry.Id;
                this.BackupID  = entry[LOG_EXTRA_BACKUPID];
                this.TaskID    = entry[LOG_EXTRA_TASKID];

                if (entry.Exception == null)
                {
                    this.ExceptionID = null;
                }
                else if (entry.Exception is Library.Interface.UserInformationException)
                {
                    this.ExceptionID = ((Library.Interface.UserInformationException)entry.Exception).HelpID;
                }
                else
                {
                    this.ExceptionID = entry.Exception.GetType().FullName;
                }
            }
コード例 #2
0
        public void WriteMessage(Duplicati.Library.Logging.LogEntry entry)
        {
            if (entry.Level < m_logLevel)
            {
                return;
            }

            if (m_serverfile != null && entry.Level >= m_serverloglevel)
            {
                try
                {
                    m_serverfile.WriteMessage(entry);
                }
                catch
                {
                }
            }

            lock (m_lock)
            {
                if (m_anytimeouts)
                {
                    var q = GetActiveTimeouts();

                    if (q.Length == 0)
                    {
                        UpdateLogLevel();
                        m_anytimeouts = false;
                        if (m_buffer == null || m_buffer.Size != INACTIVE_SIZE)
                        {
                            m_buffer = new RingBuffer <LogEntry>(INACTIVE_SIZE, m_buffer);
                        }
                    }
                }

                if (m_buffer != null)
                {
                    m_buffer.Enqueue(new LogEntry(entry));
                }
            }
        }