/// <summary>
 /// <see cref="ILoggerProvider"/> for Google Cloud Logging.
 /// </summary>
 /// <param name="consumer">The consumer to push logs to. Must not be null.</param>
 /// <param name="logTarget">Where to log to. Must not be null.</param>
 /// <param name="serviceContext">The service context to associate to log entries. May be null.</param>
 /// <param name="loggerOptions">The logger options. Must not be null.</param>
 /// <param name="serviceProvider">The service provider to resolve additional services from.</param>
 internal GoogleLoggerProvider(IConsumer <LogEntry> consumer, LogTarget logTarget, Struct serviceContext, LoggingOptions loggerOptions, IServiceProvider serviceProvider)
 {
     _consumer        = GaxPreconditions.CheckNotNull(consumer, nameof(consumer));
     _logTarget       = GaxPreconditions.CheckNotNull(logTarget, nameof(logTarget));
     _loggerOptions   = GaxPreconditions.CheckNotNull(loggerOptions, nameof(loggerOptions));
     _serviceContext  = serviceContext;
     _serviceProvider = serviceProvider;
 }
Ejemplo n.º 2
0
        internal GoogleLogger(
            IConsumer <LogEntry> consumer, LogTarget logTarget, Struct serviceContext, LoggingOptions loggerOptions,
            string logName, IClock clock = null, IServiceProvider serviceProvider = null)
#pragma warning disable CS0618 // Type or member is obsolete
            : this(consumer, logTarget, serviceContext, loggerOptions, logName, null, null, clock, serviceProvider)
#pragma warning restore CS0618 // Type or member is obsolete
        {
        }
Ejemplo n.º 3
0
 internal GoogleLogger(IConsumer <LogEntry> consumer, LogTarget logTarget, Struct serviceContext, LoggingOptions loggerOptions, string logName,
                       Action <IServiceProvider, Dictionary <string, string> > obsoleteLabelsGetter,
                       Action <IServiceProvider, LogEntry, TraceTarget> obsoleteTraceContextGetter,
                       IClock clock = null, IServiceProvider serviceProvider = null)
 {
     _logTarget   = GaxPreconditions.CheckNotNull(logTarget, nameof(logTarget));
     _traceTarget = logTarget.Kind == LogTargetKind.Project ?
                    TraceTarget.ForProject(logTarget.ProjectId) : null;
     _serviceContext             = serviceContext;
     _consumer                   = GaxPreconditions.CheckNotNull(consumer, nameof(consumer));
     _loggerOptions              = GaxPreconditions.CheckNotNull(loggerOptions, nameof(loggerOptions));
     _logName                    = GaxPreconditions.CheckNotNullOrEmpty(logName, nameof(logName));
     _fullLogName                = logTarget.GetFullLogName(_loggerOptions.LogName);
     _serviceProvider            = serviceProvider;
     _clock                      = clock ?? SystemClock.Instance;
     _obsoleteTraceContextGetter = obsoleteTraceContextGetter;
     _ambientScopeManager        = new AmbientScopeManager(_loggerOptions, _serviceProvider, obsoleteLabelsGetter);
 }
Ejemplo n.º 4
0
 internal AmbientScopeManager(LoggingOptions options, IServiceProvider serviceProvider, Action <IServiceProvider, Dictionary <string, string> > obsoleteLabelsGetter)
 {
     _permanentParent      = options?.Labels is null ? null : GoogleLoggerScope.CreateScope(new LabellingScopeState(options.Labels), null);
     _serviceProvider      = serviceProvider;
     _obsoleteLabelsGetter = obsoleteLabelsGetter;
 }