public override void ExecuteCommand()
        {
            var jobName = Arguments[0];

            // Start by fetching the latest log
            var joblogs = JobLog.LoadJobLogs(StorageAccount);

            // Grab the log
            var candidates = joblogs.Where(l => l.JobName.StartsWith(jobName, StringComparison.OrdinalIgnoreCase)).ToList();

            if (!candidates.Any())
            {
                Log.Error("No logs match: {0}", jobName);
            }
            else if (candidates.Count > 1)
            {
                Log.Error("Multiple logs match: {0}. Found: {1}", jobName, String.Join(", ", candidates.Select(c => c.JobName)));
            }
            else
            {
                // Grab the requested entries
                var log     = candidates.Single();
                var entries = log.OrderedEntries().Take(NumberOfEntries.Value).Reverse();
                foreach (var entry in entries)
                {
                    WriteEntry(log, entry);
                    _lastEntryUtc = entry.Timestamp;
                }

                if (Follow)
                {
                    FollowLog(log);
                }
            }
        }
示例#2
0
        public override void ExecuteCommand()
        {
            // Start by fetching the latest log
            var joblogs = JobLog.LoadJobLogs(StorageAccount);

            // Iterate over each log
            foreach (var joblog in joblogs)
            {
                Log.Info("Cleaning {0}", joblog.JobName);
                foreach (var blob in joblog.Blobs.Where(b => (DateTime.UtcNow - b.ArchiveTimestamp) > MaxAge.Value))
                {
                    try
                    {
                        if (!WhatIf)
                        {
                            // Only delete if it matches.
                            blob.Blob.DeleteIfExists(
                                accessCondition: AccessCondition.GenerateIfMatchCondition(blob.Blob.Properties.ETag));
                        }
                        Log.Info("Deleted {0}", blob.Blob.Name);
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorException("Failed to delete " + blob.Blob.Name, ex);
                    }
                }
            }
        }
        public override void ExecuteCommand()
        {
            var joblogs = JobLog.LoadJobLogs(StorageAccount);

            // List logs!
            Log.Info("Available Logs: ");
            foreach (var log in joblogs)
            {
                Log.Info("* {0}", log.JobName);
            }
        }