public LogItemViewModel(LogItem item) { this._item = item; SetStacktrace(); SetException(); SetProperties(); }
public frmLog(LogItem logItem) { InitializeComponent(); this.logItem = logItem; InitForm(); }
protected bool Write(string message, string level, Exception exception, Properties properties) { try { var userName = WindowsIdentity.GetCurrent() != null ? WindowsIdentity.GetCurrent().Name : String.Empty; var reflectedType = new StackFrame(2, true).GetMethod().ReflectedType; string classNamespace = reflectedType != null ? reflectedType.Namespace : String.Empty; string className = reflectedType != null ? reflectedType.Name : String.Empty; var log = new LogItem { timestamp = new BsonDateTime(DateTime.Now), level = level, thread = Thread.CurrentThread.Name, userName = userName, message = message, loggerName = GetType().Name, domain = AppDomain.CurrentDomain.FriendlyName, machineName = Environment.MachineName, fileName = new StackFrame(2, true).GetFileName(), method = new StackFrame(2, true).GetMethod().Name, lineNumber = new StackFrame(2, true).GetFileLineNumber().ToString(CultureInfo.InvariantCulture), className = String.Format("{0}.{1}", classNamespace, className) }; if (exception != null) log.exception = BuildExceptionBsonDocument(exception); log.properties = BuildPropertiesBsonDocument(properties, this.Properties); WriteConcernResult result = LogsCollection.Insert(log); return result.Ok; } catch (MongoException ex) { string str = String.Format("Ошибка записи в базу. {0}", ex.Message); throw new LoggerWriteException(str, ex); } }
public bool Remove(LogItem item) { if (item == null) return false; try { IMongoQuery query = Query.EQ("_id", item.Id); WriteConcernResult result = LogsCollection.Remove(query); return result.DocumentsAffected == 1; } catch (MongoException ex) { string str = String.Format("Ошибка удаления из базы. {0}", ex.Message); throw new LoggerDeleteException(str, ex); } }