Esempio n. 1
0
        protected string BuildLog(M4MLogLevel logLevel, string message, string exceptionMessage, string stackTrace, string callerMemberName, string callerFilePath, int callerLineNumber)
        {
            var header = BuildLogInternal(logLevel, message, callerMemberName, callerFilePath, callerLineNumber);
            header.Append("\n" + exceptionMessage).Append("\n" + stackTrace);

            return header.ToString();
        }
Esempio n. 2
0
        private StringBuilder BuildLogInternal(M4MLogLevel logLevel, string message, string callerMemberName, string callerFilePath, int callerLineNumber)
        {
            var header = new StringBuilder("\n");

            switch (logLevel)
            {
                case M4MLogLevel.Debug:
                    header.Append("[DEBUG] ");
                    break;

                case M4MLogLevel.Info:
                    header.Append("[INFO] ");
                    break;

                case M4MLogLevel.Warn:
                    header.Append("[WARN] ");
                    break;

                case M4MLogLevel.Error:
                    header.Append("[ERROR] ");
                    break;
            }

            header.Append(DateTime.Now.ToString("HH:mm:ss"));

            if (callerFilePath.Equals("") == false && callerMemberName.Equals("") == false)
            {
                header.Append("\n");
                header.Append("File : '").Append(callerFilePath).Append("'\n");
                header.Append("Method : '").Append(callerMemberName).Append("'");

                if (callerLineNumber != -1)
                {
                    header.Append(" at line '").Append(callerLineNumber).Append("'");
                }

                header.Append("\n" + message + "\n");
            }

            return header;
        }
Esempio n. 3
0
 protected string BuildLog(M4MLogLevel logLevel, string message, string callerMemberName, string callerFilePath, int callerLineNumber)
 {
     return BuildLogInternal(logLevel, message, callerMemberName, callerFilePath, callerLineNumber).ToString();
 }