Exemple #1
0
 /// <summary>
 /// Write values from the given log entry to the stream
 /// </summary>
 /// <param name="row">collection of columns, values, and conversions</param>
 public void LogEntry(LogRow row)
 {
     if (this.ManageWriterState(row))
     {
         this.writer.LogEntry(row);
     }
 }
Exemple #2
0
        /// <summary>
        /// Create a HistoryRow from the given LogRow.
        /// </summary>
        /// <param name="row"></param>
        public HistoryRow(LogRow row)
        {
            this.names = new string[row.ColumnCount];
            for (int index = 0; index < row.ColumnCount; index++)
            {
                this.names[index] = row.Columns[index].Parameter.Name;
            }

            this.values = new string[row.ColumnCount];
            for (int index = 0; index < row.Columns.Count; index++)
            {
                this.values[index] = row.Columns[index].ValueAsString;
            }
        }
Exemple #3
0
        /// <summary>
        /// Private constructor, use factory instead
        /// </summary>
        /// <param name="profile"></param>
        private InternalLogProfile(LogProfile profile, ParameterDatabase database)
        {
            if (Debugger.IsAttached)
            {
                this.stackTrace = new StackTrace();
            }

            this.profile  = profile;
            this.database = database;

            List <LogColumn> columns = new List <LogColumn>();

            this.AddColumnsAndDependents(columns, this.profile);
            this.addresses = BuildAddressList(columns);

            ReadOnlyCollection <LogColumn> readOnly = columns.AsReadOnly();
            LogRow row = LogRow.GetInstance(readOnly);

            this.logEventArgs = new LogEventArgs(row, profile.UserData);
        }
Exemple #4
0
        /// <summary>
        /// Indicate whether this row should be logged
        /// </summary>
        private bool ShouldLog(LogRow row)
        {
            // For the immutable filter types
            if (this.parameter == null)
            {
                return(this.ShouldLog((LogColumn)null));
            }

            // The real logic
            foreach (LogColumn column in row.Columns)
            {
                if (column.Parameter.Id == this.parameter.Id)
                {
                    return(this.ShouldLog(column));
                }
            }

            // This row doesn't contain the parameter that the log filter expects.
            // This is not unusual; the next one probably will.
            return(false);
        }
Exemple #5
0
        /// <summary>
        /// Create and dispose log writer as necessary
        /// </summary>
        /// <param name="row">row of data from the SSM interface</param>
        /// <returns>true if </returns>
        private bool ManageWriterState(LogRow row)
        {
            if (this.ShouldLog(row))
            {
                if (this.writer == null)
                {
                    this.writer = this.factory();

                    if (this.queue.Count == 0)
                    {
                        this.writer.LogStart(row);
                    }
                    else
                    {
                        ILogRow first = this.queue.Dequeue();
                        this.writer.LogStart(first);
                        this.writer.LogEntry(first);

                        while (this.queue.Count > 0)
                        {
                            this.writer.LogEntry(this.queue.Dequeue());
                        }
                    }
                }
                return(true);
            }
            else
            {
                // Keep the values from the most recent N rows in the queue for later replay.
                this.queue.Enqueue(new HistoryRow(row));
                if (this.queue.Count > extraRows)
                {
                    this.queue.Dequeue();
                }

                this.SafelyDisposeWriter();
                return(false);
            }
        }
Exemple #6
0
 internal LogEventArgs(LogRow row, object userData)
 {
     this.row      = row;
     this.userData = userData;
 }
Exemple #7
0
 /// <summary>
 /// Write the names of the colums
 /// </summary>
 /// <param name="row">collection of columns, values, and conversions</param>
 public void LogStart(LogRow row)
 {
     this.ManageWriterState(row);
 }