using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
using Tango.PMR.Debugging;
namespace Tango.Integration.Logging
{
public class EmbeddedLogItem : MessageLogItem
{
///
/// Gets or sets the debug log response.
///
public StartDebugLogResponse DebugLogResponse { get; set; }
private int _repeated;
///
/// Gets or sets the number of times this message has been received continuously.
///
public int Repeated
{
get { return _repeated; }
set { _repeated = value; RaisePropertyChanged(nameof(Repeated)); RaisePropertyChanged(nameof(MessagePlusRepeated)); }
}
///
/// Initializes a new instance of the class.
///
/// The debug log response.
public EmbeddedLogItem(StartDebugLogResponse debugLogResponse)
{
Repeated = 1;
DebugLogResponse = debugLogResponse;
Category = (LogCategory)debugLogResponse.Category;
Message = debugLogResponse.Message;
CallerFile = debugLogResponse.FileName;
CallerLineNumber = (int)debugLogResponse.LineNumber;
}
///
/// Returns a that represents this instance.
///
///
/// A that represents this instance.
///
public override string ToString()
{
return String.Format("[{0}] [{1}] [{2}] [{3}] [{4}] [{5}]: {6}", TimeStamp.ToString("HH:mm:ss.ff"), DebugLogResponse.Category, Path.GetFileName(DebugLogResponse.FileName), DebugLogResponse.LineNumber, DebugLogResponse.ModuleId, DebugLogResponse.Filter, DebugLogResponse.Message);
}
///
/// Gets the message plus repeated.
///
public String MessagePlusRepeated
{
get { return Repeated > 1 ? String.Format("{0} ({1})", Message, Repeated) : Message; }
}
///
/// Gets the relative caller file path.
///
///
protected override string GetRelativeCallerFilePath()
{
return CallerFile;
}
}
}