示例#1
0
        private void LogMessage(FileLogInfo fileLogInfo)
        {
            string logMessage = string.Empty;

            // [ HOW THE MESSAGE SHOULD BE PRESENTED ]
            switch (fileLogInfo.Presentation)
            {
            case Presentation.FULL_DETAIL: logMessage = MessageLogUtility.GenerateFullLogDetail(fileLogInfo, source, eventID); break;

            case Presentation.LOG_WITH_SEVERITY: logMessage = MessageLogUtility.GenerateLogWithSeverity(fileLogInfo, false); break;

            case Presentation.LOG__ONLY: logMessage = MessageLogUtility.GenerateLogOnly(fileLogInfo, isException: false); break;

            case Presentation.CUSTOM: logMessage = fileLogInfo.LogMessage.Trim(); break;
            }

            string pathTillDrive = FileUtils.CheckOrCreateLogDirectory(fileLogInfo);

            WriteToFile(fileLogInfo, logMessage, pathTillDrive, appendLine: true);

            //// [ HOW THE MESSAGE SHOULD BE INSERTED ]   ------- WORK OUT HERE >>
            //switch (fileLogInfo.InsertionType)
            //{
            //    case InsertionType.Append:
            //        WriteToFile(fileLogInfo, logMessage, pathTillDrive, appendLine: true);
            //        break;

            //    case InsertionType.NewFile:
            //        WriteToFile(fileLogInfo, logMessage, pathTillDrive, appendLine: true);
            //        break;
            //}
        }
示例#2
0
        private void LogException(FileLogInfo fileLogInfo)
        {
            string logMessage = string.Empty;

            switch (fileLogInfo.Presentation)
            {
            case Presentation.FULL_DETAIL: logMessage = MessageLogUtility.GenerateFullLogDetail_EX(fileLogInfo, source, eventID); break;

            case Presentation.LOG_WITH_SEVERITY: logMessage = MessageLogUtility.GenerateLogWithSeverity(fileLogInfo, true); break;

            case Presentation.LOG__ONLY:
            default: logMessage = MessageLogUtility.GenerateLogOnly(fileLogInfo, isException: true); break;

            case Presentation.CUSTOM: break;
            }

            string pathTillDrive = FileUtils.CheckOrCreateLogDirectory(fileLogInfo);

            WriteToFile(fileLogInfo, logMessage, pathTillDrive, appendLine: true);
        }