Example #1
0
        public ObjectLog(ObjectLogSchema schema, ObjectLogConfiguration configuration)
        {
            this.configuration = configuration;
            this.schemaEntries = ObjectLog <T> .GetSchemaEntries(schema);

            this.logSchema = ObjectLog <T> .GetLogSchema(schema, this.schemaEntries);

            this.log = new Log(configuration.FilenamePrefix, new LogHeaderFormatter(this.logSchema, LogHeaderCsvOption.CsvStrict), configuration.LogComponentName, true);
            this.log.Configure(configuration.LoggingFolder, configuration.MaxLogAge, configuration.MaxLogDirSize, configuration.MaxLogFileSize, configuration.BufferLength, configuration.StreamFlushInterval, configuration.Note, configuration.FlushToDisk);
        }
Example #2
0
        public static List <IObjectLogPropertyDefinition <T> > GetSchemaEntries(ObjectLogSchema schema)
        {
            List <IObjectLogPropertyDefinition <T> > list = new List <IObjectLogPropertyDefinition <T> >();

            FieldInfo[] fields = schema.GetType().GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            foreach (FieldInfo fieldInfo in fields)
            {
                object          value           = fieldInfo.GetValue(null);
                ObjectLogSchema objectLogSchema = value as ObjectLogSchema;
                if (objectLogSchema != null)
                {
                    list.AddRange(ObjectLog <T> .GetSchemaEntries(objectLogSchema));
                }
                else
                {
                    IObjectLogPropertyDefinition <T> objectLogPropertyDefinition = value as IObjectLogPropertyDefinition <T>;
                    if (objectLogPropertyDefinition != null)
                    {
                        if (schema.ExcludedProperties == null || !schema.ExcludedProperties.Contains(objectLogPropertyDefinition.FieldName))
                        {
                            list.Add(objectLogPropertyDefinition);
                        }
                    }
                    else
                    {
                        IEnumerable <IObjectLogPropertyDefinition <T> > enumerable = value as IEnumerable <IObjectLogPropertyDefinition <T> >;
                        if (enumerable != null)
                        {
                            foreach (IObjectLogPropertyDefinition <T> objectLogPropertyDefinition2 in enumerable)
                            {
                                if (schema.ExcludedProperties == null || !schema.ExcludedProperties.Contains(objectLogPropertyDefinition2.FieldName))
                                {
                                    list.Add(objectLogPropertyDefinition2);
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }
Example #3
0
        public static LogSchema GetLogSchema(ObjectLogSchema schema)
        {
            List <IObjectLogPropertyDefinition <T> > list = ObjectLog <T> .GetSchemaEntries(schema);

            return(ObjectLog <T> .GetLogSchema(schema, list));
        }
 public static LogSchema GetLogSchema()
 {
     return(ObjectLog <FailureObjectLog.FailureObjectLogEntry> .GetLogSchema(new FailureObjectLog.FailureObjectLogSchema()));
 }