Exemple #1
0
        /// <summary>
        /// Get the log message, formatted as Date, Message, LogType
        /// </summary>
        /// <param name="useLocalTime">When true, use the local time, otherwise use UTC time</param>
        /// <param name="timestampFormat">Timestamp format mode</param>
        /// <returns>Formatted message (does not include anything regarding MessageException)</returns>
        public string GetFormattedMessage(
            bool useLocalTime = true,
            TimestampFormatMode timestampFormat = DEFAULT_TIMESTAMP_FORMAT)
        {
            var formatString = GetTimestampFormatString(timestampFormat);

            string timeStamp;

            if (useLocalTime)
            {
                timeStamp = MessageDateLocal.ToString(formatString);
            }
            else
            {
                timeStamp = MessageDateUTC.ToString(formatString);
            }

            return(string.Format("{0}, {1}, {2}", timeStamp, Message, LogLevel.ToString()));
        }
Exemple #2
0
        private string GetTimestampFormatString(TimestampFormatMode timestampFormat)
        {
            switch (timestampFormat)
            {
            case TimestampFormatMode.MonthDayYear24hr:
                return(DATE_TIME_FORMAT_MONTH_DAY_YEAR_24H);

            case TimestampFormatMode.MonthDayYear12hr:
                return(DATE_TIME_FORMAT_MONTH_DAY_YEAR_12H);

            case TimestampFormatMode.YearMonthDay24hr:
                return(DATE_TIME_FORMAT_YEAR_MONTH_DAY_24H);

            case TimestampFormatMode.YearMonthDay12hr:
                return(DATE_TIME_FORMAT_YEAR_MONTH_DAY_12H);

            default:
                return(GetTimestampFormatString(DEFAULT_TIMESTAMP_FORMAT));
            }
        }
Exemple #3
0
 /// <summary>
 /// Get the log message, formatted in the form Date, Message, LogType
 /// </summary>
 /// <param name="timestampFormat">Timestamp format mode</param>
 /// <returns>Formatted message (does not include anything regarding MessageException)</returns>
 public string GetFormattedMessage(TimestampFormatMode timestampFormat)
 {
     return(GetFormattedMessage(true, timestampFormat));
 }