public override void Log(CustomLogDefinition log) { if (!settingsProvider.Get(LoggerSettings.SupportBulkLogs)) { throw new NotSupportedException("Bulk logs not supported in this installation. Please contact {C}.".ReplaceBranding()); } if (!settingsProvider.Get(LoggerSettings.SupportCustomLogs)) { throw new NotSupportedException("Custom Logs not supported in this installation. Please contact {C} support.".ReplaceBranding()); } SendLog(log); }
public static void Log(CustomLogDefinition log) { try { if (!ApplicationMonitoringEnabled) { return; } LoggerInstance.Log(log); } catch (NotSupportedException) { throw; } catch (Exception e) { logthrottle.WriteErrorWithThrottle(EventLogger.WriteError, "Error sending log: " + e.ToString()); } }
public CustomLog(object ssRecord) { if (ssRecord is IRecord) { // Record inspection: // - get structure field from record // - get its EntityRecordDetails attribute // - there must be a single structure in the record (this is an entity record and not a recordjoin) EntityRecordDetails entityDetails = null; if (ssRecord is ISimpleRecord) { entityDetails = ssRecord.GetType().GetCustomAttributes(typeof(EntityRecordDetails), false).FirstOrDefault() as EntityRecordDetails; } else { var entAttr = ssRecord.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance) .Select( field => new { Field = field, EntityDetails = field.FieldType.GetCustomAttributes(typeof(EntityRecordDetails), false).FirstOrDefault() }) .Where(fa => fa.EntityDetails != null) .FirstIfSingleOrDefault(); if (entAttr != null) { entityDetails = (EntityRecordDetails)entAttr.EntityDetails; ssRecord = entAttr.Field.GetValue(ssRecord); } } if (entityDetails != null) { var entityName = entityDetails.Name; var entityGeneration = entityDetails.Generation; var physicalTableName = entityDetails.PhysicalTableName; var dbConnection = entityDetails.DBConnection; var structAttrs = ssRecord.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); // This method uses cache var dbCatalog = DatabaseAccess.ForEspaceDatabase(ObjectKeyUtils.DatabaseValue(ObjectKey.Parse(entityDetails.OwnerKey))).DatabaseServices.DatabaseConfiguration.DatabaseIdentifier; log = new CustomLogDefinition(entityName: entityName, physicalTableName: physicalTableName, dbConnection: dbConnection, entityGeneration: entityGeneration, dbCatalog: dbCatalog); for (int i = 0; i < structAttrs.Length; i++) { var attrs = (Attribute[])structAttrs[i].GetCustomAttributes(typeof(EntityAttributeDetails), false); if (attrs.Length == 1) { EntityAttributeDetails entityAttributeDetails = (EntityAttributeDetails)attrs[0]; if (!entityAttributeDetails.IsAutonumber) { var customLogField = new CustomLogDefinition.CustomLogFieldDefinition(structAttrs[i].GetValue(ssRecord), entityAttributeDetails.IsEntityReference, entityAttributeDetails.IsMandatory); log.Fields.Add(entityAttributeDetails.Name, customLogField); } } } return; } } throw new InvalidCastException("Unable to convert to record"); }
public override void Log(CustomLogDefinition log) { }
public abstract void Log(CustomLogDefinition log);