/// <summary> /// Adds a <see cref="GoogleLoggerProvider"/> for <see cref="GoogleLogger"/>s. /// </summary> /// <param name="factory">The logger factory. Cannot be null.</param> /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine. /// The Google Cloud Platform project ID. If unspecified and running on GAE or GCE the project ID will be /// detected from the platform.</param> /// <param name="options">Optional, options for the logger.</param> /// <param name="client">Optional, logging client.</param> public static ILoggerFactory AddGoogle(this ILoggerFactory factory, string projectId = null, LoggerOptions options = null, LoggingServiceV2Client client = null) { options = options ?? LoggerOptions.Create(); projectId = Project.GetAndCheckProjectId(projectId, options.MonitoredResource); return(factory.AddGoogle(LogTarget.ForProject(projectId), options, client)); }
/// <summary> /// Create an <see cref="ILoggerProvider"/> for Google Stackdriver Logging. /// </summary> /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine. /// The Google Cloud Platform project ID. If unspecified and running on GAE or GCE the project ID will be /// detected from the platform.</param> /// <param name="options">Optional, options for the logger.</param> /// <param name="client">Optional, logging client.</param> public static GoogleLoggerProvider Create(string projectId = null, LoggerOptions options = null, LoggingServiceV2Client client = null) { options = options ?? LoggerOptions.Create(); projectId = Project.GetAndCheckProjectId(projectId, options.MonitoredResource); return(Create(LogTarget.ForProject(projectId), options, client)); }
/// <summary> /// Adds a <see cref="GoogleLoggerProvider"/> for <see cref="GoogleLogger"/>s. /// </summary> /// <param name="factory">The logger factory. Cannot be null.</param> /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine. /// The Google Cloud Platform project ID. If unspecified and running on GAE or GCE the project ID will be /// detected from the platform.</param> /// <param name="options">Optional, options for the logger.</param> /// <param name="client">Optional, logging client.</param> public static ILoggerFactory AddGoogle(this ILoggerFactory factory, string projectId = null, LoggerOptions options = null, LoggingServiceV2Client client = null) { GaxPreconditions.CheckNotNull(factory, nameof(factory)); projectId = Project.GetAndCheckProjectId(projectId, options.MonitoredResource); return(factory.AddGoogle(LogTarget.ForProject(projectId), options, client)); }
public void Project() { string projectId = "pid"; LogTarget logTarget = LogTarget.ForProject(projectId); Assert.Equal(LogTargetKind.Project, logTarget.Kind); Assert.Equal(projectId, logTarget.ProjectId); Assert.Null(logTarget.OrganizationId); }
public void GetFullLogName_Project() { string projectId = "pid"; string name = "name"; LogTarget logTarget = LogTarget.ForProject(projectId); string projectName = logTarget.GetFullLogName(name); Assert.Contains(name, projectName); Assert.Contains(projectId, projectName); }
/// <summary> /// Adds a <see cref="GoogleLoggerProvider"/> for <see cref="GoogleLogger"/>s. /// </summary> /// <param name="builder">The logger builder. Cannot be null.</param> /// <param name="serviceProvider">The service provider to resolve additional services from.</param> /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine. /// The Google Cloud Platform project ID. If unspecified and running on GAE or GCE the project ID will be /// detected from the platform.</param> /// <param name="options">Optional, options for the logger.</param> /// <param name="client">Optional, logging client.</param> public static void AddGoogle(this ILoggingBuilder builder, IServiceProvider serviceProvider, string projectId = null, LoggerOptions options = null, LoggingServiceV2Client client = null) { GaxPreconditions.CheckNotNull(builder, nameof(builder)); options = options ?? LoggerOptions.Create(); projectId = Project.GetAndCheckProjectId(projectId, options.MonitoredResource); LogTarget logTarget = LogTarget.ForProject(projectId); var provider = GoogleLoggerProvider.Create(serviceProvider, projectId, options, client); builder.Services.AddSingleton <ILoggerProvider>(provider); }
/// <summary> /// Adds a <see cref="GoogleLoggerProvider"/> for <see cref="GoogleLogger"/>s. /// </summary> /// <param name="factory">The logger factory. Cannot be null.</param> /// <param name="projectId">The Google Cloud Platform project ID. Cannot be null.</param> /// <param name="options">Optional, options for the logger.</param> /// <param name="client">Optional, logging client.</param> public static ILoggerFactory AddGoogle(this ILoggerFactory factory, string projectId, LoggerOptions options = null, LoggingServiceV2Client client = null) { GaxPreconditions.CheckNotNull(projectId, nameof(projectId)); return(factory.AddGoogle(LogTarget.ForProject(projectId), options, client)); }