/* F  L O A D */

        /*----------------------------------------------------------------------------
        *       %%Function: FLoad
        *       %%Qualified: AzLog.AzLogAzureTable.FLoad
        *       %%Contact: rlittle
        *
        *   Load the information about this datasource, but don't actually open it
        *   (doesn't ping the net or validate information)
        *  ----------------------------------------------------------------------------*/
        public bool FLoad(AzLogModel azlm, string sRegRoot, string sName)
        {
            string sKey = String.Format("{0}\\Datasources\\{1}", sRegRoot, sName);

            // save everything we need to be able to recreate ourselves
            Settings ste = new Settings(_rgsteeDatasource, sKey, "ds");

            ste.Load();
            m_sFilename = ste.SValue("FileName");
            m_sName     = sName;

            m_tlc = TextLogConverter.CreateFromConfig(ste.SValue("LogTextFormat"));

            return(true);
        }
Beispiel #2
0
        public static void TestParseLine(string sConfig, string sLine, string sPartitionExpected, string sRowKeyExpected, string sTickCountExpected, string sAppNameExpected,
                                         string sLevelExpected, string sEventIDExpected, string sInstanceIDExpected, string sPidExpected, string sTidExpected, string sMessageRawExpected,
                                         string sMessage0Expected,
                                         string sMessage1Expected, string sMessage2Expected, string sMessage3Expected, string sMessage4Expected, string sMessage5Expected, string sMessage6Expected,
                                         string sMessage7Expected, string sMessage8Expected, string sMessage9Expected)
        {
            TextLogConverter tlc          = TextLogConverter.CreateFromConfig(sConfig);
            AzLogEntry       azle         = tlc.ParseLine(sLine, 0);
            AzLogEntry       azleExpected = new AzLogEntry();

            azleExpected.InitMessageParts(10);

            azleExpected.SetColumn(AzLogEntry.LogColumn.Partition, sPartitionExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.RowKey, sRowKeyExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.EventTickCount, sTickCountExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.AppName, sAppNameExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Level, sLevelExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.EventID, sEventIDExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.InstanceID, sInstanceIDExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Pid, sPidExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Tid, sTidExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message, sMessageRawExpected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message0, sMessage0Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message1, sMessage1Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message2, sMessage2Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message3, sMessage3Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message4, sMessage4Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message5, sMessage5Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message6, sMessage6Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message7, sMessage7Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message8, sMessage8Expected);
            azleExpected.SetColumn(AzLogEntry.LogColumn.Message9, sMessage9Expected);


            AssertAzleEqual(azle, azleExpected);
        }
Beispiel #3
0
        /*----------------------------------------------------------------------------
        *   %%Function: CreateFromConfig
        *   %%Qualified: AzLog.TextLogConverter.CreateFromConfig
        *   %%Contact: rlittle
        *
        *   Config language:
        *
        *   This config defines how to parse a text line into an AzLogEntry, which
        *   has a set of predefined columns, as well as custom columns. See
        *   AzLogEntry.LogColummn for the set of constants we are mapping to.
        *
        *   Column definition:
        *
        *   [0-9]+  this is the column we are mapping to
        *   ["+"]   an optional "+" character, which means this column is copied to
        *           another builtin column:
        *           [0-9]+  the other column we are mapping to
        *   [,:t?]  what is the separator character
        *           , means its a comma
        *           : means its a colon
        *           t means its \t
        *           ? means we have a fixed width, with the width following:
        *           [0-9]+  the fixed width, followed by a space (to terminate the
        *                   width)
        *  ----------------------------------------------------------------------------*/
        public static TextLogConverter CreateFromConfig(string sConfig)
        {
            TextLogConverter tlc = new TextLogConverter();

            int ich, ichNext;
            int ichMac = sConfig.Length;

            ich = 0;
            while (ich < ichMac)
            {
                ichNext = ich;
                int nCol = -1;

                nCol = ParseColumn(sConfig, ich, ref ichNext, ichMac);

                int nColCopy = -1;

                if (sConfig[ichNext] == '+') // this means they want to copy this field to another column too
                {
                    int ichFirstCopy = ++ichNext;

                    nColCopy = ParseColumn(sConfig, ichFirstCopy, ref ichNext, ichMac);
#if no
                    while (ichNext < ichMac && char.IsDigit(sConfig[ichNext]))
                    {
                        ichNext++;
                    }

                    if (ichNext >= ichMac)
                    {
                        throw new Exception("bad config format -- no terminating separator after column copy");
                    }

                    nColCopy = int.Parse(sConfig.Substring(ichFirstCopy, ichNext - ichFirstCopy));
#endif // no
                }

                char          chSep = sConfig[ichNext];
                TextLogColumn tlcc  = new TextLogColumn();
                tlcc.Column = (AzLogEntry.LogColumn)nCol;
                if (nColCopy != -1)
                {
                    tlcc.ColumnCopy = (AzLogEntry.LogColumn)nColCopy;
                }

                if (chSep == ',')
                {
                    tlcc.Separator = TextLogColumn.Sep.Comma;
                }
                else if (chSep == ':')
                {
                    tlcc.Separator = TextLogColumn.Sep.Colon;
                }
                else if (chSep == 't')
                {
                    tlcc.Separator = TextLogColumn.Sep.Tab;
                }
                else if (chSep == '?')
                {
                    tlcc.Separator = TextLogColumn.Sep.FixedWidth;

                    int ichFirst = ++ichNext;

                    // the next digits are the cch
                    while (ichNext < ichMac && char.IsDigit(sConfig[ichNext]))
                    {
                        ichNext++;
                    }

                    if (ichFirst >= ichNext)
                    {
                        throw new Exception("bad config format -- no length for fixed width column");
                    }

                    if (sConfig[ichNext] != ' ')
                    {
                        throw new Exception("bad config format -- fixed width column width was not terminated with a space");
                    }

                    tlcc.Cch = int.Parse(sConfig.Substring(ichFirst, ichNext - ichFirst));
                }
                else
                {
                    throw new Exception("bad config format. unknown separator");
                }

                tlc.m_pltlc.Add(tlcc);
                ich = ichNext + 1;
            }

            return(tlc);
        }