コード例 #1
0
        private void HandleAccountSelected(object sender, EventArgs e)
        {
            string accountname = GetSelectedAccountName();
            string accountkey = GetSelectedAccountKey();
            if (accountkey == null)
                return;
            IEnumerable<string> tableNames = null;

            PerformBG(this, () =>
            {
                tableNames = new LogFetcher(accountname, accountkey).FetchTables();
            },
            () =>
            {
                tableSelection.Items.Clear();
                tableSelection.Items.Add("-- select table --");
                foreach (var tablename in tableNames)
                    tableSelection.Items.Add(tablename);
                tableSelection.SelectedIndex = 0;
                UpdateAccountSelection();
            }, (ex) =>
            {
                if (MessageBox.Show(this, "Failed to retrieve tables for this storage account. Do you want to remove this account?", "Error", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    if (Configuration.Instance.Accounts.ContainsKey(GetSelectedAccountName()))
                        Configuration.Instance.Accounts.Remove(GetSelectedAccountName());
                }
                UpdateAccountSelection();
            });
        }
コード例 #2
0
 /// <summary>
 /// Downloads the Windows Azure Diagnostics (WAD) log of the given
 /// instance's mongod. This is slow and expensive (it requires a
 /// full blob fetch), and the logs are out-of-date by up to a minute
 /// but it works when the instance is down.
 /// </summary>
 public ActionResult DownloadAzureLog(int id)
 {
     SetFileDownloadHeaders("instance" + id + ".log", "text/plain");
     LogFetcher.WriteEntireLog(Response, id);
     Response.Close();
     return(null);
 }
コード例 #3
0
ファイル: LogProcessor.cs プロジェクト: Grummle/W3CLogToMongo
 public LogProcessor(W3CLogReaderFactory readerFactory, LogFetcher logFetcher, StateRecorder stateRecorder,
                     LogPersisterFactory persisterFactory, Logger logger)
 {
     _readerFactory = readerFactory;
     _logFetcher = logFetcher;
     _stateRecorder = stateRecorder;
     _persisterFactory = persisterFactory;
     _logger = logger;
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: watawave/MasterManager
        private static void Main()
        {
            ILog log = LogFetcher.GetLogger();

            log.Info("===== Program Start");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IMainMDIView     mainMDIView      = new MainMDIForm();
            MainMDIPresenter mainMDIPresenter = new MainMDIPresenter(mainMDIView);

            log.Info("===== Program.CSよりMDI子フォームを起動");
            mainMDIView.ShowMDIChildForm();
            log.Info("===== Program.CSよりMDI親フォームを起動");
            mainMDIView.ShowView();

            log.Info("===== Program End");
        }
コード例 #5
0
        public void SetUp()
        {
            _logger = new FakeLogger();
            _logFetcher = new LogFetcher();
            _stateRecorder = new FakeStateRecorder();
            _logPersisterFactory = Substitute.For<LogPersisterFactory>();
            _logPersister = new FakePersister(); //Substitute.For<ILogPersister>();
            _logPersisterFactory.GetPersister(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>()).Returns(
                _logPersister);
            _logProcessor = new LogProcessor(new W3CLogReaderFactory(_logger), _logFetcher, _stateRecorder,
                                             _logPersisterFactory, _logger);

            _source = new Configuration.source();
            _source.destination = new Configuration.source.logDestination();
            _source.id = "int.test";
            _source.conversions.Add(new Configuration.source.conversion {elementName = "sc-status", type = "int"});

            _source.logDirectory = "../../Logs/";
            _source.destination.mongoConnectionString = "blarg";
            _source.destination.mongoCollection = "blarg";
            _source.destination.mongoDatabase = "blarg";
        }
コード例 #6
0
        private void HandleFetchButton(object sender, EventArgs e)
        {
            string accountName = GetSelectedAccountName();
            string accountKey = GetSelectedAccountKey();
            if (accountName == null)
            {
                MessageBox.Show(this, "Please select an account to fetch first...");
                return;
            }
            string table = GetSelectedTableName();
            if (table == null)
            {
                MessageBox.Show(this, "Please select a table to fetch first...");
                return;
            }
            DateTime from = fromDate.Value;
            DateTime to = toDate.Value;

            OrderBy order = (OrderBy)Enum.Parse(typeof(OrderBy), orderByCombo.SelectedItem + "");

            IList<WadTableEntity> entities = null;
            PerformBG(this, () =>
            {
                // Find results for this period in time
                entities = new LogFetcher(accountName, accountKey).FetchLogs(table, from, to);
                switch (order)
                {
                    case OrderBy.New_to_Old:
                        entities = entities.OrderByDescending(i => i.EventTickCount).ThenByDescending(i => i.Timestamp).ToList();
                        break;
                    case OrderBy.Old_to_New:
                        entities = entities.OrderBy(i => i.EventTickCount).ThenBy(i => i.Timestamp).ToList();
                        break;
                }

                // If there are no entities at all, add a dummy "no results" entity
                if (entities == null || entities.Count == 0)
                {
                    entities = new List<WadTableEntity>();
                    var entity = new WadTableEntity {
                        PartitionKey = "No results found. Try extending the from/to period."
                    };
                    entity.Properties.Add("PartitionKey", entity.PartitionKey);
                    entities.Add(entity);
                }

                // Determine the available property names by checking each entity
                string[] propertyNames = entities.SelectMany(entity => entity.Properties).Select(p => p.Key).Distinct().ToArray();

                // If certain propertynames are available, we assume this is a Windows Azure Diagnostics table and we leave out some info
                if (propertyNames.Contains("EventTickCount") &&
                    propertyNames.Contains("RoleInstance") &&
                    propertyNames.Contains("Level") &&
                    propertyNames.Contains("Message"))
                {
                    _loadedColumns = new string[] { "RoleInstance", "Timestamp", "Message" };
                    _loadedRows = (from i in entities select new[] { i.RoleInstance, i.Timestamp.ToString(), i.Message }).ToArray();
                    _filteredRows = _loadedRows;
                    return;
                }
                else
                {
                    _loadedColumns = (from propname in propertyNames select propname).ToArray();
                    _loadedRows = (from entity in entities
                                   select (from prop in entity.Properties select prop.Value).ToArray()).ToArray();
                    _filteredRows = _loadedRows;
                }
            },
            () =>
            {
                dataGridView1.ReadOnly = true;
                if (!dataGridView1.VirtualMode)
                {
                    dataGridView1.VirtualMode = true;
                    dataGridView1.CellValueNeeded += HandleCellValueNeeded;
                }
                dataGridView1.AllowUserToAddRows = false;
                dataGridView1.AllowUserToDeleteRows = false;
                dataGridView1.AllowUserToResizeColumns = true; // Resizen mag wel
                dataGridView1.AllowUserToResizeRows = false;
                dataGridView1.AllowUserToOrderColumns = false;
                dataGridView1.Columns.Clear();
                dataGridView1.Rows.Clear();
                foreach (var column in _loadedColumns)
                {
                    dataGridView1.Columns.Add(column, column);
                }

                // Vind van elke kolom de langste waarde
                string[] dummyvals = Enumerable.Repeat("", _loadedColumns.Length).ToArray();
                for (int i = 0; i < _loadedColumns.Length; i++)
                {
                    string longest = (from item in _loadedRows select item[i]).Aggregate("", (max, cur) => max.Length > cur.Length ? max : cur);
                    //longest = new string('#', longest.Length);
                    dummyvals[i] = longest;
                }

                // Voeg een dummy record toe
                dataGridView1.VirtualMode = false;
                dataGridView1.Rows.Add(dummyvals);

                // Autosize alle kolommen
                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                // Breedtes van kolommen vastzetten
                foreach (DataGridViewColumn column in dataGridView1.Columns)
                {
                    int width = column.Width + 15; // Compensate character width a little, so we don't get "..." on the slightest difference
                    column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                    column.Width = width;
                }

                // Haal de autosize weer weg
                dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

                // Rowcount goed zetten
                dataGridView1.Rows.Clear();
                dataGridView1.VirtualMode = true;
                dataGridView1.RowCount = _loadedRows.Length;

                // Als er een filter is, pas het filter toe...
                if (GetFilterText() != null)
                    HandleFilterKeyup(this, EventArgs.Empty);
            });
        }
コード例 #7
0
 public void Setup()
 {
     lf = new LogFetcher();
     path = @"../../Logs/";
 }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: martijns/AzureLogViewer
        private void HandleFetchButton(object sender, EventArgs e)
        {
            string accountName = GetSelectedAccountName();
            string accountKey  = GetSelectedAccountKey();

            if (accountName == null)
            {
                MessageBox.Show(this, "Please select an account to fetch first...");
                return;
            }
            string table = GetSelectedTableName();

            if (table == null)
            {
                MessageBox.Show(this, "Please select a table to fetch first...");
                return;
            }
            DateTime from = fromDate.Value;
            DateTime to   = toDate.Value;

            OrderBy order = (OrderBy)Enum.Parse(typeof(OrderBy), orderByCombo.SelectedItem + "");

            IList <WadTableEntity> entities = null;

            statusStrip1.Visible = true;
            PerformBG(this, () =>
            {
                // Find results for this period in time
                _currentFetcher = new LogFetcher(accountName, accountKey)
                {
                    UseWADPerformanceOptimization = Configuration.Instance.UseWADPerformanceOptimization,
                    UseKarellPartitionKey         = Configuration.Instance.UseKarellPartitionKey,
                    UseKarellRowKey = Configuration.Instance.UseKarellRowKey
                };
                _currentFetcher.RetrievedPage += HandleRetrievedPage;
                entities = _currentFetcher.FetchLogs(table, from, to);
                switch (order)
                {
                case OrderBy.New_to_Old:
                    entities = entities.OrderByDescending(i => i.EventTickCount).ThenByDescending(i => i.Timestamp).ToList();
                    break;

                case OrderBy.Old_to_New:
                    entities = entities.OrderBy(i => i.EventTickCount).ThenBy(i => i.Timestamp).ToList();
                    break;
                }

                var index = 0;
                foreach (var item in entities)
                {
                    item.LineNumber = index++;
                }

                // If there are no entities at all, add a dummy "no results" entity
                if (entities == null || entities.Count == 0)
                {
                    entities   = new List <WadTableEntity>();
                    var entity = new WadTableEntity
                    {
                        PartitionKey = "No results found. Try extending the from/to period. If you were expecting results, you could try disabling 'Use optimized queries for WAD tables'.",
                        RowKey       = ""
                    };
                    entities.Add(entity);
                }

                // Determine the available property names by checking each entity
                string[] propertyNames = entities.SelectMany(entity => entity.Properties).Select(p => p.Key).Distinct().ToArray();

                // If certain propertynames are available, we assume this is a Windows Azure Diagnostics table and we leave out some info
                if ("WADLogsTable".Equals(table) &&
                    propertyNames.Contains("DeploymentId") &&
                    propertyNames.Contains("RoleInstance") &&
                    propertyNames.Contains("EventTickCount") &&
                    propertyNames.Contains("Message"))
                {
                    _loadedColumns = new string[] { "", "DeploymentId", "RoleInstance", "EventTickCount", "Message" };
                    _loadedRows    = (from i in entities select new[] { i.LineNumber.ToString(), i.DeploymentId, i.RoleInstance, new DateTime(i.EventTickCount).ToString("yyyy-MM-dd HH:mm:ss.fff"), i.Message }).ToArray();
                    _filteredRows  = _loadedRows;
                }
                else if ("WADPerformanceCountersTable".Equals(table) &&
                         propertyNames.Contains("Timestamp") &&
                         propertyNames.Contains("EventTickCount") &&
                         propertyNames.Contains("DeploymentId") &&
                         propertyNames.Contains("RoleInstance") &&
                         propertyNames.Contains("CounterName") &&
                         propertyNames.Contains("CounterValue"))
                {
                    _loadedColumns = new string[] { "Timestamp", "EventTickCount", "DeploymentId", "RoleInstance", "CounterName", "CounterValue" };
                    _loadedRows    = (from i in entities select new[] { i.Timestamp.ToString(), new DateTime(i.EventTickCount).ToString("yyyy-MM-dd HH:mm:ss.fff"), i.DeploymentId, i.Properties["RoleInstance"], i.Properties["CounterName"], i.Properties["CounterValue"] }).ToArray();
                    _filteredRows  = _loadedRows;
                }
                else
                {
                    _loadedColumns = new[] { "PartitionKey", "RowKey", "Timestamp" }.Concat(from propname in propertyNames select propname).ToArray();
                    _loadedRows    = (from entity in entities
                                      select(new[] { entity.PartitionKey, entity.RowKey, entity.Timestamp.ToString("yyyy-MM-dd HH:mm:ss.fff") }.Concat(from prop in entity.Properties select GetPropertyValue(prop))).ToArray()).ToArray();
                    _filteredRows = _loadedRows;
                }
            },
                      () =>
            {
                if ("WADPerformanceCountersTable".Equals(table) && _loadedRows.Length > 1 /* the dummy if empty */ && Configuration.Instance.ShowPerformanceCountersAsChart)
                {
                    ShowPerformanceCountersChart();
                }
                else
                {
                    ShowDataGridView();
                }
                statusStrip1.Visible = false;
            });
        }