/// <summary> /// Adds the specified log entry. /// </summary> /// <param name="item">The log entry.</param> public void Add(LogEntry item) { if (!this.DatabaseIsCreated) { this.CreateDatabase(); this.CreateTable(); } this.SaveResult(item); }
/// <summary> /// Saves the result. /// </summary> /// <param name="logEntry">The log entry.</param> private void SaveResult(LogEntry logEntry) { string scriptFormat = @"INSERT INTO {0} (Message, Version, StackTrace, ExceptionType) VALUES (@Message, @Version, @StackTrace, @ExceptionType)"; string script = string.Format( CultureInfo.InvariantCulture, scriptFormat, TableName); this.ExecuteCommand( script, new SqlParameter("Message", logEntry.Message), new SqlParameter("Version", LogEntry.Version), BaseSqlAdo.GetNvarcharParameter("StackTrace", logEntry.StackTrace), BaseSqlAdo.GetNvarcharParameter("ExceptionType", logEntry.ExceptionType)); }
/// <summary> /// Adds the log entry. /// </summary> /// <param name="logEntry">The log entry.</param> private void AddLogEntry(LogEntry logEntry) { this.logEntryRepository.Add(logEntry); }
/// <summary> /// Logs an error. /// </summary> /// <param name="message">The message.</param> public void LogError(string message) { var logEntry = new LogEntry(message); this.AddLogEntry(logEntry); }
/// <summary> /// Logs the exception as an error. /// </summary> /// <param name="exception">The exception.</param> public void LogError(Exception exception) { var logEntry = new LogEntry(exception); this.AddLogEntry(logEntry); }
/// <summary> /// Logs the exception as an error. /// </summary> /// <param name="exception">The exception.</param> /// <param name="message">The message.</param> public void LogError(Exception exception, string message) { var logEntry = new LogEntry(exception, message); this.AddLogEntry(logEntry); }