Click here to Skip to main content
13,145,774 members (63,279 online)
Click here to Skip to main content

Stats

4.8K views
5 bookmarked
Posted 22 Oct 2013
BSD

Collect and Compare Log Statistics using LogJoin

, 22 Oct 2013
The LogJoin tool helps to collect any unstructured data from text files and join it to a simple table representation for easy analysis.
/*
 * Copyright (c) 2013, Yuriy Nelipovich
 * 
 * If you find this code useful or in case of any questions, suggestions
 * bug reports, donation, please email me: dev.yuriy.n@gmail.com
 */

using System.Configuration;
using System.Linq;

namespace LogJoin.Config
{
    public class InputAttributes : ConfigurationElement
    {
        private const char ColumnNamesSeparator = ',';

        [ConfigurationProperty("dirPath", IsRequired = true)]
        public ConfigurationTextElement<string> DirPathElement
        {
            get { return (ConfigurationTextElement<string>) this["dirPath"]; }
            set { this["dirPath"] = value; }
        }

        public string DirPath
        {
            get { return this.DirPathElement.Value; }
        }

        [ConfigurationProperty("fileName", IsRequired = true)]
        public ConfigurationTextElement<string> FileNameMaskElement
        {
            get { return (ConfigurationTextElement<string>) this["fileName"]; }
            set { this["fileName"] = value; }
        }

        public string FileNameMask
        {
            get { return this.FileNameMaskElement.Value; }
        }

        [ConfigurationProperty("name", IsRequired = true)]
        public string SourceName
        {
            get { return (string) (this["name"]); }
            set { this["name"] = value; }
        }

        [ConfigurationProperty("columns", IsRequired = true)]
        public ConfigurationTextElement<string> ColumnNamesElement
        {
            get { return (ConfigurationTextElement<string>) this["columns"]; }
            set { this["columns"] = value; }
        }

        public string[] ColumnNames
        {
            get
            {
                return this.ColumnNamesElement.Value
                           .Split(ColumnNamesSeparator)
                           .Select(s => s.Trim()).ToArray();
            }
        }

        [ConfigurationProperty("regEx", IsRequired = true)]
        public ConfigurationTextElement<string> RegExNameElement
        {
            get { return (ConfigurationTextElement<string>) this["regEx"]; }
            set { this["regEx"] = value; }
        }

        public string RegExName
        {
            get { return this.RegExNameElement.Value; }
        }

        [ConfigurationProperty("key", IsRequired = true)]
        public ConfigurationTextElement<string> KeyNamesElement
        {
            get { return (ConfigurationTextElement<string>) this["key"]; }
            set { this["key"] = value; }
        }

        public string[] KeyNames
        {
            get
            {
                return this.KeyNamesElement.Value
                           .Split(ColumnNamesSeparator)
                           .Select(s => s.Trim()).ToArray();
            }
        }

        [ConfigurationProperty("lines", IsRequired = false, DefaultValue = 1)]
        public int MaxLinesCount
        {
            get { return (int) this["lines"]; }
            set { this["lines"] = value; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

Yuriy Nelipovich
Software Developer CactusSoft
Belarus Belarus
No Biography provided

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 22 Oct 2013
Article Copyright 2013 by Yuriy Nelipovich
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid