Exemplo n.º 1
0
        public ILogger CreateLogger(LoggerParameters loggerParameters)
        {
            string assemblyName = null;
            string assemblyFile = null;

            if (File.Exists(loggerParameters.Assembly))
            {
                assemblyFile = loggerParameters.Assembly;
            }
            else
            {
                assemblyName = loggerParameters.Assembly;
            }

            var loggerDescription = new LoggerDescription(
                loggerParameters.ClassName,
                assemblyName,
                assemblyFile,
                loggerParameters.Parameters,
                loggerParameters.Verbosity);

            var logger = loggerDescription.CreateLogger();

            return(Wrap(logger));
        }
Exemplo n.º 2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var loggerParameters = new LoggerParameters
            {
                Assembly   = Assembly,
                ClassName  = ClassName,
                Parameters = Parameters,
                Verbosity  = Verbosity
            };

            var logger = Factory.InvokeInstance.CreateLogger(loggerParameters);

            WriteObject(logger);
        }
Exemplo n.º 3
0
        public void Initialize(IEventSource eventSource)
        {
            var parameters = LoggerParameters.Parse(this.Parameters);

            _solutionDirectory = parameters["SolutionDir"];

            var verbosityString = parameters["Verbosity"];

            Verbosity = !string.IsNullOrEmpty(verbosityString) && Enum.TryParse(verbosityString, out LoggerVerbosity verbosity)
                ? verbosity
                : LoggerVerbosity.Normal;

            var ignoredTargets = new string[]
            {
                "GetCopyToOutputDirectoryItems",
                "GetNativeManifest",
                "GetTargetPath",
                "GetTargetFrameworks",
            };

            _ignoredTargets = new HashSet <string>(ignoredTargets, StringComparer.OrdinalIgnoreCase);

            // TargetsNotLogged is an optional parameter.
            var targetsNotLogged = parameters["TargetsNotLogged"];

            if (!string.IsNullOrEmpty(targetsNotLogged))
            {
                _ignoredTargets.UnionWith(targetsNotLogged.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }

            eventSource.ErrorRaised    += OnErrorRaised;
            eventSource.WarningRaised  += OnWarningRaised;
            eventSource.ProjectStarted += OnProjectStarted;

            IEventSource2 eventSource2 = eventSource as IEventSource2;

            eventSource2.TelemetryLogged += OnTelemetryLogged;

            if (Verbosity == LoggerVerbosity.Diagnostic)
            {
                eventSource.ProjectFinished += OnProjectFinished;
            }
        }