Exemple #1
0
        /* H A N D L E  C O N T E X T  O P E N I N G */

        /*----------------------------------------------------------------------------
        *       %%Function: HandleContextOpening
        *       %%Qualified: AzLog.AzLogWindow.HandleContextOpening
        *       %%Contact: rlittle
        *
        *   This is going to get executed every time they go to open a context menu.
        *   We want to know *where* they are invoking from, so we do some clever
        *   hacker in HeaderSup.ColumnHeaderFromContextOpening(...) -- it figures out
        *   (based on the client rects of the column header items) where they are
        *   clicking and which column header is appropriate.
        *
        *   NOTE: IF it locates a ColumnHeader and returns it to you, then
        *   ColumnHeaderFromContextOpeneing CANCELS the context menu operation
        *   from here from happening and assumes you are going to invoke the context
        *   menu yourself (which is why we conly call m_ctxmHeader.Show() when
        *   we get a columnheader back - this allows us to show our ContextMenu
        *   for our Header columns instead of the context menu for the rest of the
        *   listview)
        *
        *   ALSO NOTE that we squirrel away the matched columnheader into the first
        *   menu item in the context menu -- in our case, that's the
        *   "Remove this column" menu item, so it follows that it needs to know
        *   what "this" column is.  (Other routings may choose to look here for this
        *   information, so let's make sure to clear the Tag in times when we aren't
        *   matched...)
        *  ----------------------------------------------------------------------------*/
        private void HandleContextOpening(object sender, CancelEventArgs e)
        {
            if (m_hs == null)
            {
                m_hs = new HeaderSupp();
            }

            ColumnHeader ch = m_hs.ColumnHeaderFromContextOpening(m_lvLog, sender, e);

            if (ch != null)
            {
                m_ctxmHeader.Tag           = ch;
                m_ctxmHeader.Items[0].Text = "Remove column " + ch.Text;
                m_ctxmHeader.Show(Control.MousePosition);
            }
            else
            {
                // we aren't in the column headers. now customize our context menu
                Point        ptLocal = m_lvLog.PointToClient(Cursor.Position);
                ListViewItem lvi     = m_lvLog.GetItemAt(ptLocal.X, ptLocal.Y);
                AzLogEntry   azle    = (AzLogEntry)lvi.Tag;

                ch = TCore.ListViewSupp.HeaderSupp.ColumnFromPoint(m_lvLog, ptLocal.X);
                AzLogViewSettings.AzLogViewColumn azlvc = m_azlvs.AzlvcFromName((string)ch.Tag);
                ContextMenuContext cmc = new ContextMenuContext();
                cmc.azle = azle;
                cmc.lc   = azlvc.DataColumn;
                m_ctxmListViewLog.Items[0].Tag  = cmc;
                m_ctxmListViewLog.Items[0].Text = String.Format("Filter to this {0}", ch.Text);
                m_ctxmListViewLog.Items[1].Tag  = cmc;
                m_ctxmListViewLog.Items[1].Text = String.Format("Filter out this {0}", ch.Text);
                m_ctxmListViewLog.Items[2].Tag  = cmc;
                m_ctxmListViewLog.Items[2].Text = String.Format("Color this {0}", ch.Text);
            }
        }
Exemple #2
0
        public void TestAzLogEntryEntityConstructor()
        {
            AzLogEntryEntity azlee = new AzLogEntryEntity();

            azlee.PartitionKey    = "Partition";
            azlee.RowKey          = Guid.Empty.ToString();
            azlee.InstanceId      = "a000";
            azlee.EventTickCount  = 1;
            azlee.EventId         = 2;
            azlee.Level           = "Level";
            azlee.ApplicationName = "AppName";
            azlee.Pid             = 3;
            azlee.Tid             = 4;
            azlee.Message         = "Message";

            AzLogEntry azle = AzLogEntry.Create(azlee);

            Assert.AreEqual("Partition", azle.Partition);
            Assert.AreEqual(Guid.Empty, azle.RowKey);
            Assert.AreEqual(1, azle.EventTickCount);
            Assert.AreEqual("AppName", azle.ApplicationName);
            Assert.AreEqual("Level", azle.Level);
            Assert.AreEqual(2, azle.EventId);
            Assert.AreEqual("0000A000", azle.InstanceId);
            Assert.AreEqual(3, azle.Pid);
            Assert.AreEqual(4, azle.Tid);
            Assert.AreEqual("Message", azle.Message);
        }
Exemple #3
0
        /* A P P E N D  I T E M  T O  V I E W */

        /*----------------------------------------------------------------------------
        *       %%Function: AppendItemToView
        *       %%Qualified: AzLog.AzLogView.AppendItemToView
        *       %%Contact: rlittle
        *
        *   Append a single item to our view -- make sure it matches our filter
        *  ----------------------------------------------------------------------------*/
        private void AppendItemToView(int i)
        {
            AzLogEntry azle = m_azlm.LogEntry(i);

            if (m_azlf.FEvaluate(azle))
            {
                m_pliale.Add(i);
            }
        }
        public async Task LoadCompleteModel(AzLogModel azlm)
        {
            AzLogEntry[] rgazle = new AzLogEntry[s_cChunkSize]; // do 1k log entry chunks

            using (StreamReader sr = File.OpenText(m_sFilename))
            {
                int iLine = 0;
                int cChunk = 0;
                int iFirst, iLast;

                while (!sr.EndOfStream)
                {
                    string     s    = sr.ReadLine();
                    AzLogEntry azle = null;
                    try
                    {
                        azle = AzleFromLine(s, iLine++);
                    }
                    catch
                    {
                    }

                    if (azle == null)
                    {
                        continue;
                    }

                    DateTime dttm = AzLogModel.DttmFromPartition(azle.Partition);
                    if (m_dttmFirst > dttm)
                    {
                        m_dttmFirst = dttm;
                    }
                    if (m_dttmLast < dttm)
                    {
                        m_dttmLast = dttm;
                    }

                    rgazle[cChunk++] = azle;

                    if (cChunk >= s_cChunkSize)
                    {
                        azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast);
                        cChunk = 0;
                    }
                }
                if (cChunk > 0)
                {
                    azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast);
                }
            }
        }
Exemple #5
0
        public void TestAzLogEntryConstructor()
        {
            AzLogEntry azle = AzLogEntry.Create("Partition", Guid.Empty, 1, "AppName", "Level", 2, "a000", 3, 4,
                                                "Message");

            Assert.AreEqual("Partition", azle.Partition);
            Assert.AreEqual(Guid.Empty, azle.RowKey);
            Assert.AreEqual(1, azle.EventTickCount);
            Assert.AreEqual("AppName", azle.ApplicationName);
            Assert.AreEqual("Level", azle.Level);
            Assert.AreEqual(2, azle.EventId);
            Assert.AreEqual("0000A000", azle.InstanceId);
            Assert.AreEqual(3, azle.Pid);
            Assert.AreEqual(4, azle.Tid);
            Assert.AreEqual("Message", azle.Message);
        }
Exemple #6
0
        public void AddTestDataPartition(DateTime dttmPartition, Int64[] rgTickCount, string [] rgs)
        {
            AzLogEntries azles = new AzLogEntries();

            for (int i = 0; i < rgTickCount.Length; i++)
            {
                Int64  nTickCount = rgTickCount[i];
                string s          = rgs == null ? "msg" : rgs[i];

                AzLogEntry azle = AzLogEntry.Create(dttmPartition.ToString("yyyyMMddHH"), Guid.NewGuid(), nTickCount, "testdata", "Informational",
                                                    1, "2", 3, 4, s);

                m_azles.AddLogEntry(azle);
            }

            azles.UpdatePart(dttmPartition, dttmPartition.AddHours(1), AzLogParts.GrfDatasourceForIDatasource(1), AzLogPartState.Complete);
        }
Exemple #7
0
        static int ParseColumn(string sConfig, int ichFirst, ref int ichNext, int ichMac)
        {
            if (sConfig[ichNext] == '`')
            {
                // `LogColumn` is a named version for the column. convert this to a physical index
                ichNext++;
                while (ichNext < ichMac && sConfig[ichNext] != '`')
                {
                    ichNext++;
                }

                if (sConfig[ichNext] != '`')
                {
                    throw new Exception("bad config format - no matching ` for column name");
                }

                string sColumnName = sConfig.Substring(ichFirst + 1, ichNext - ichFirst - 1);
                ichNext++;
                if (ichNext >= ichMac)
                {
                    throw new Exception("bad config format -- no terminating separator");
                }

                return((int)AzLogEntry.GetColumnIndexByName(sColumnName));
            }

            while (ichNext < ichMac && char.IsDigit(sConfig[ichNext]))
            {
                ichNext++;
            }

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

            return(int.Parse(sConfig.Substring(ichFirst, ichNext - ichFirst)));
        }
Exemple #8
0
 static private void AssertAzleEqual(AzLogEntry azle, AzLogEntry azleExpected)
 {
     Assert.AreEqual(azleExpected.Partition, azle.Partition);
     Assert.AreEqual(azleExpected.RowKey, azle.RowKey);
     Assert.AreEqual(azleExpected.EventTickCount, azle.EventTickCount);
     Assert.AreEqual(azleExpected.ApplicationName, azle.ApplicationName);
     Assert.AreEqual(azleExpected.Level, azle.Level);
     Assert.AreEqual(azleExpected.EventId, azle.EventId);
     Assert.AreEqual(azleExpected.InstanceId, azle.InstanceId);
     Assert.AreEqual(azleExpected.Pid, azle.Pid);
     Assert.AreEqual(azleExpected.Tid, azle.Tid);
     Assert.AreEqual(azleExpected.Message, azle.Message);
     Assert.AreEqual(azleExpected.Message0, azle.Message0);
     Assert.AreEqual(azleExpected.Message1, azle.Message1);
     Assert.AreEqual(azleExpected.Message2, azle.Message2);
     Assert.AreEqual(azleExpected.Message3, azle.Message3);
     Assert.AreEqual(azleExpected.Message4, azle.Message4);
     Assert.AreEqual(azleExpected.Message5, azle.Message5);
     Assert.AreEqual(azleExpected.Message6, azle.Message6);
     Assert.AreEqual(azleExpected.Message7, azle.Message7);
     Assert.AreEqual(azleExpected.Message8, azle.Message8);
     Assert.AreEqual(azleExpected.Message9, azle.Message9);
 }
Exemple #9
0
        public void TestMessageSplit(string sPartition, string sMessage, string[] rgsExpected)
        {
            AzLogModel azlm = new AzLogModel();

            m_azlf = new AzLogFilter(); // just get a default empty one

            azlm.AddTestDataPartition(DateTime.Parse(sPartition), new Int64[] { 10 }, new string[] { sMessage });

            BuildView(azlm, new CompareLogEntryTickCount(azlm));

            AzLogEntry azle = AzleItem(0);

            Assert.AreEqual(rgsExpected[0], azle.Message);
            Assert.AreEqual(rgsExpected[1], azle.Message0);
            Assert.AreEqual(rgsExpected[2], azle.Message1);
            Assert.AreEqual(rgsExpected[3], azle.Message2);
            Assert.AreEqual(rgsExpected[4], azle.Message3);
            Assert.AreEqual(rgsExpected[5], azle.Message4);
            Assert.AreEqual(rgsExpected[6], azle.Message5);
            Assert.AreEqual(rgsExpected[7], azle.Message6);
            Assert.AreEqual(rgsExpected[8], azle.Message7);
            Assert.AreEqual(rgsExpected[9], azle.Message8);
        }
Exemple #10
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);
        }
Exemple #11
0
        /* P A R S E  L I N E */

        /*----------------------------------------------------------------------------
        *   %%Function: ParseLine
        *   %%Qualified: AzLog.AzLogFile.TextLogConverter.ParseLine
        *   %%Contact: rlittle
        *
        *  ----------------------------------------------------------------------------*/
        public AzLogEntry ParseLine(string sLine, int nLine)
        {
            AzLogEntry azle = new AzLogEntry();

            azle.InitMessageParts(10);

            int ilc     = 0;
            int ich     = 0;
            int ichLast = 0;

            int ichMac = sLine.Length;

            while (ilc < m_pltlc.Count)
            {
                ichLast = 0;

                TextLogColumn tlc = m_pltlc[ilc];

                // by definition we are already positioned at the beginning of this column except for possible whitespace
                // skip leading whitespace exc
                while (ich < ichMac && sLine[ich] == ' ')
                {
                    ich++;
                }

                if (ich >= ichMac)
                {
                    if (ilc < m_pltlc.Count)
                    {
                        return(null);
                    }
                    break;
                }
                int ichEnd = 0;

                // look for the separator
                if (tlc.Separator == TextLogColumn.Sep.Comma)
                {
                    if (!FParseQuotedCommaColumn(sLine, ich, ref ichLast, ref ichEnd, ichMac, ilc + 1 == m_pltlc.Count))
                    {
                        return(null);
                    }

                    // else, we'll calculate ichLim below
                }
                else if (tlc.Separator == TextLogColumn.Sep.FixedWidth)
                {
                    if (!FParseFixedWidthColumn(sLine, tlc.Cch, ich, ref ichLast, ref ichEnd, ichMac, ilc + 1 == m_pltlc.Count))
                    {
                        return(null);
                    }
                }

                if (ichLast == 0)
                {
                    if (ilc + 1 == m_pltlc.Count)
                    {
                        ichEnd = ichLast = sLine.Length - 1;
                    }
                    else
                    {
                        char chSep = TextLogColumn.CharFromSep(tlc.Separator);
                        ichLast = sLine.IndexOf(chSep, ich);
                        if (ichLast == -1)
                        {
                            return(null); // couldn't find the separator for this column
                        }
                        ichLast--;        // we want this to point to the last char, not to the separator
                        ichEnd = ichLast;
                    }
                }
                // at this point we have ich pointing to start of string; ichEnd pointing to last char before the separator (maybe a quote),
                // at ichLast pointing to just before the separator (never a quote)
                //, lets trim the string
                int ichFirst = ich;


                if (sLine[ichFirst] == '"' && sLine[ichEnd] == '"')
                {
                    ichFirst++;
                    ichEnd--;
                }

                while (ichEnd > ichFirst && sLine[ichEnd] == ' ')
                {
                    ichEnd--;
                }

                // now we have the string
                if (tlc.Column == AzLogEntry.LogColumn.EventTickCount)
                {
                    DateTime dttm = DateTime.Parse(sLine.Substring(ichFirst, ichEnd - ichFirst + 1));
                    dttm = dttm.ToUniversalTime();

                    azle.SetColumn(AzLogEntry.LogColumn.Partition, dttm.ToString("yyyyMMddHH"));
                    azle.EventTickCount = dttm.Ticks + nLine;
                    if (tlc.ColumnCopy != AzLogEntry.LogColumn.Nil)
                    {
                        azle.SetColumn(tlc.ColumnCopy, dttm.ToString("MM/dd/yyyy HH:mm:ss"));
                    }

                    // and manufacture a partition as well
                    azle.SetColumn(AzLogEntry.LogColumn.Partition, AzLogModel.SPartitionFromDate(dttm, dttm.Hour));
                }
                else
                {
                    azle.SetColumn(tlc.Column, sLine.Substring(ichFirst, ichEnd - ichFirst + 1));
                }

                if (tlc.Separator == TextLogColumn.Sep.FixedWidth)
                {
                    ich = ichLast;
                }
                else
                {
                    ich = ichLast + 2;
                }
                ilc++;
                if (ich >= ichMac)
                {
//                    if (ilc < m_pltlc.Count)
//                        return null;
                    break;
                }
            }

            //
            return(azle);
        }