public void Log(CSCloudLogEntry logEntry)
 {
     using (CSCloudEntities db = new CSCloudEntities())
     {
         db.Logs.Add(LogToModel(logEntry));
         db.SaveChanges();
     }
 }
        private Log LogToModel(CSCloudLogEntry log)
        {
            var l = new Log();
            l.Date = log.Date;
            l.Severity = log.Severity.ToString();
            l.Message = log.Message;
            l.StackTrace = log.StackTrace;

            return l;
        }
Пример #3
0
        public static CSCloudLogEntry FromResponse(CSCloudResponse response, CSCloudSeverity severity, string message, string stackTrace = null)
        {
            if (response == null) return null;

            CSCloudLogEntry log = new CSCloudLogEntry();
            log.Date = DateTime.UtcNow;
            log.Severity = severity;

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(response.ToString());
            if (message != null) sb.AppendLine().Append(message);
            if (stackTrace != null) sb.AppendLine().AppendLine(stackTrace);
            log.Message = sb.ToString();

            return log;
        }