Exemple #1
0
        public string ToString(LogStringDetailLevel logStringDetailLevel)
        {
            string exType       = "";
            string exStackTrace = "";

            if (Exception != null)
            {
                exType       = "Ex. type: " + Exception.GetType().Name + ".";
                exStackTrace = "Stacktrace: " + Exception.StackTrace + ".";
            }

            switch (logStringDetailLevel)
            {
            case LogStringDetailLevel.Complete:
                return(String.Format("{0} [{1}]: {2}. Location: {3} at {4}. {5}", Timestamp, Level, Message, OriginatingFunction, SourceCodeLocation, exType));

            case LogStringDetailLevel.CompleteWithExceptionBacktrace:
                return(String.Format("{0} [{1}]: {2}. Location: {3} at {4}. {5} {6}", Timestamp, Level, Message, OriginatingFunction, SourceCodeLocation, exType, exStackTrace));

            case LogStringDetailLevel.Message:
                return(String.Format("{0} [{1}]: {2}.", Timestamp, Level, Message));

            case LogStringDetailLevel.MessageAndFunction:
                return(String.Format("{0} [{1}]: {2}. Method: {3}. {4}", Timestamp, Level, Message, OriginatingFunction, exType));

            case LogStringDetailLevel.MessageAndLocation:
                return(String.Format("{0} [{1}]: {2}. Location: {3}. {4}", Timestamp, Level, Message, SourceCodeLocation, exType));

            default:
                return(ToString());
            }
        }
Exemple #2
0
 public IEnumerable <string> GetLogEntriesAsString(LogStringDetailLevel detailLevel = LogStringDetailLevel.MessageAndFunction)
 {
     return(entries.Select(x => x.ToString(detailLevel)));
 }