Ejemplo n.º 1
0
        private static Logger CreateLogger([NotNull] IManifestHelper manifest, CreateLoggerOptions createLoggerOptions)
        {
            var logName = string.IsNullOrWhiteSpace(createLoggerOptions.Name)
                ? manifest.Key
                : $"{manifest.Key}.{createLoggerOptions.Name}";

            var outputs = new List <ILogOutput>();

            if (createLoggerOptions.File > LogLevel.None)
            {
                outputs.Add(
                    new FileOutput(Path.Combine(BasePluginLogPath, $"{logName}.log"), createLoggerOptions.File)
                    );
            }

            if (createLoggerOptions.Console > LogLevel.None)
            {
                outputs.Add(new ConciseConsoleOutput(createLoggerOptions.Console));
            }

            var immutableOutputs = outputs.ToImmutableList();

            Debug.Assert(immutableOutputs != null, $"{nameof(immutableOutputs)} != null");

            return(new Logger(
                       new LogConfiguration
            {
                LogLevel = LogConfiguration.Default.LogLevel,
                Outputs = immutableOutputs
            }
                       ));
        }
Ejemplo n.º 2
0
 // ReSharper disable once NotNullMemberIsNotInitialized
 // Plugin instance is created at the Discovery phase and Configuration is loaded afterwards
 private Plugin(
     [NotNull] IManifestHelper manifest,
     [NotNull] ILoggingHelper logging,
     [NotNull] PluginReference reference
     )
 {
     Manifest  = manifest;
     Logging   = logging;
     Reference = reference;
 }
 // ReSharper disable once NotNullMemberIsNotInitialized
 // Plugin instance is created at the Discovery phase and Configuration is loaded afterwards
 private Plugin(
     IManifestHelper manifest,
     ILoggingHelper logging,
     PluginReference reference
     )
 {
     Manifest  = manifest;
     Logging   = logging;
     Reference = reference;
 }
Ejemplo n.º 4
0
        internal LoggingHelper([NotNull] Logger applicationLogger, [NotNull] IManifestHelper manifest)
        {
            mManifest = manifest;

            Application = applicationLogger;
            Plugin      = CreateLogger(
                manifest, new CreateLoggerOptions
            {
                Console = Debugger.IsAttached ? LogLevel.Debug : LogLevel.None,
                File    = LogLevel.Info
            }
                );
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a <see cref="Plugin"/> instance for the given context, manifest and reference.
 /// </summary>
 /// <param name="applicationContext">the <see cref="IApplicationContext"/> the plugin is running in</param>
 /// <param name="manifest">the <see cref="IManifestHelper"/> that describes this plugin</param>
 /// <param name="reference">the <see cref="PluginReference"/> with pre-searched reflection information</param>
 /// <returns></returns>
 internal static Plugin Create(
     [NotNull] IApplicationContext applicationContext,
     [NotNull] IManifestHelper manifest,
     [NotNull] PluginReference reference
     ) => new Plugin(manifest, new LoggingHelper(applicationContext.Logger, manifest), reference);