/// <summary> /// Show logs that matches the source information. /// </summary> /// <param name="window">A <seealso cref="LogsViewerToolWindow"/> object. </param> /// <param name="log">A <seealso cref="LogItem"/> object.</param> public static void FilterOnSourceLocation(this LogsViewerToolWindow window, LogItem log) { StringBuilder filter = new StringBuilder(); filter.AppendLine($"resource.type=\"{log.Entry.Resource.Type}\""); filter.AppendLine($"logName=\"{log.Entry.LogName}\""); filter.AppendLine($"{SourceLocationQueryName}.{nameof(LogEntrySourceLocation.File)}=\"{log.SourceFilePath.Replace(@"\", @"\\")}\""); filter.AppendLine($"{SourceLocationQueryName}.{nameof(LogEntrySourceLocation.Function)}=\"{log.Function}\""); filter.AppendLine($"{SourceLocationQueryName}.{nameof(LogEntrySourceLocation.Line)}=\"{log.SourceLine}\""); window.ViewModel.FilterLog(filter.ToString()); }
/// <summary> /// Show logs that only contain the GCE VM Instance id label, /// that is under resource type of gce_instance /// </summary> /// <param name="window">A <seealso cref="LogsViewerToolWindow"/> object. </param> /// <param name="instanceId">The VM instance Id.</param> public static void FilterVMInstanceLog(this LogsViewerToolWindow window, string instanceId) { if (window?.ViewModel == null || String.IsNullOrWhiteSpace(instanceId)) { Debug.WriteLine("Invalid input at FilterVMInstanceLog"); return; } StringBuilder filter = new StringBuilder(); filter.AppendLine($"resource.type=\"{ResourceTypeNameConsts.GceInstanceType}\""); filter.AppendLine($"resource.labels.instance_id=\"{instanceId}\""); window.ViewModel.FilterLog(filter.ToString()); }
/// <summary> /// Show logs that only contain the GAE service id label, /// that is under resource type of gae_app. /// </summary> /// <param name="window">A <seealso cref="LogsViewerToolWindow"/> object. </param> /// <param name="serviceId">GAE service id. Expect non null value input.</param> /// <param name="version"> /// GAE service version. Null is valid input, that it will then return logs of all versions. /// </param> public static void FilterGAEServiceLog(this LogsViewerToolWindow window, string serviceId, string version = null) { if (window?.ViewModel == null || String.IsNullOrWhiteSpace(serviceId)) { Debug.WriteLine("Invalid input at FilterVMInstanceLog"); return; } StringBuilder filter = new StringBuilder(); filter.AppendLine($"resource.type=\"{ResourceTypeNameConsts.GaeAppType}\""); filter.AppendLine($"resource.labels.module_id=\"{serviceId}\""); if (!String.IsNullOrWhiteSpace(version)) { filter.AppendLine($"resource.labels.version_id=\"{version}\""); } window.ViewModel.FilterLog(filter.ToString()); }