本文整理汇总了C#中LoggerVerbosity类的典型用法代码示例。如果您正苦于以下问题:C# LoggerVerbosity类的具体用法?C# LoggerVerbosity怎么用?C# LoggerVerbosity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoggerVerbosity类属于命名空间,在下文中一共展示了LoggerVerbosity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAsync
internal static async Task<BuildResult> BuildAsync(this BuildManager buildManager, ITestOutputHelper logger, ProjectCollection projectCollection, ProjectRootElement project, string target, IDictionary<string, string> globalProperties = null, LoggerVerbosity logVerbosity = LoggerVerbosity.Detailed, ILogger[] additionalLoggers = null)
{
Requires.NotNull(buildManager, nameof(buildManager));
Requires.NotNull(projectCollection, nameof(projectCollection));
Requires.NotNull(project, nameof(project));
globalProperties = globalProperties ?? new Dictionary<string, string>();
var projectInstance = new ProjectInstance(project, globalProperties, null, projectCollection);
var brd = new BuildRequestData(projectInstance, new[] { target }, null, BuildRequestDataFlags.ProvideProjectStateAfterBuild);
var parameters = new BuildParameters(projectCollection);
var loggers = new List<ILogger>();
loggers.Add(new ConsoleLogger(logVerbosity, s => logger.WriteLine(s.TrimEnd('\r', '\n')), null, null));
loggers.AddRange(additionalLoggers);
parameters.Loggers = loggers.ToArray();
buildManager.BeginBuild(parameters);
var result = await buildManager.BuildAsync(brd);
buildManager.EndBuild();
return result;
}
示例2: BuildScenario
public static ITargetResult BuildScenario(string scenarioName, object properties = null, string target = "GetPackageContents", ITestOutputHelper output = null, LoggerVerbosity? verbosity = null)
{
var projectName = scenarioName;
if (scenarioName.StartsWith("given", StringComparison.OrdinalIgnoreCase))
projectName = string.Join("_", scenarioName.Split('_').Skip(2));
var scenarioDir = Path.Combine(ModuleInitializer.BaseDirectory, "Scenarios", scenarioName);
string projectOrSolution;
if (File.Exists(Path.Combine(scenarioDir, $"{projectName}.csproj")))
projectOrSolution = Path.Combine(scenarioDir, $"{projectName}.csproj");
else
projectOrSolution = Directory.EnumerateFiles(scenarioDir, "*.csproj").First();
var logger = default(ILogger);
if (output != null)
{
if (verbosity == null)
{
var data = Thread.GetNamedDataSlot(nameof(LoggerVerbosity));
if (data != null)
verbosity = (LoggerVerbosity?)Thread.GetData(data);
}
logger = new TestOutputLogger(output, verbosity);
}
if (properties != null)
return Build(projectOrSolution, target,
properties: properties.GetType().GetProperties().ToDictionary(prop => prop.Name, prop => prop.GetValue(properties).ToString()),
logger: logger)[target];
else
return Build(projectOrSolution, target, logger: logger)[target];
}
示例3: CmdLineBuilder
public CmdLineBuilder(CSBuildConfig config, LoggerVerbosity? verbosity, string groups, string[] targetNames, string[] propertySets)
{
_config = config;
_verbosity = verbosity;
_groups = groups;
_targetNames = targetNames;
_propertySets = propertySets;
_thread = new System.Threading.Thread(this.Build);
}
示例4: SDConsoleLogger
public SDConsoleLogger(IBuildFeedbackSink feedbackSink, LoggerVerbosity verbosity)
: base(verbosity)
{
if (feedbackSink == null)
throw new ArgumentNullException("feedbackSink");
this.feedbackSink = feedbackSink;
this.ShowSummary = false;
base.WriteHandler = Write;
}
示例5: InitializeConsoleMethods
/// <summary>
/// Initializes the logger, with alternate output handlers.
/// </summary>
/// <param name="verbosity"></param>
/// <param name="write"></param>
/// <param name="colorSet"></param>
/// <param name="colorReset"></param>
public SerialConsoleLogger
(
LoggerVerbosity verbosity,
WriteHandler write,
ColorSetter colorSet,
ColorResetter colorReset
)
{
InitializeConsoleMethods(verbosity, write, colorSet, colorReset);
}
示例6: DebugMctLogger
/// <summary>
/// Creates a new instance of the <see cref="DebugMctLogger" /> class.
/// </summary>
/// <param name="verbosity">The verbosity of the <see cref="MctLogger" />.</param>
public DebugMctLogger(LoggerVerbosity verbosity)
{
Verbosity = verbosity;
if (!Debugger.IsAttached)
try
{
Debugger.Launch();
}
catch { }
}
示例7: CheckVerbosity
private static void CheckVerbosity(string errorMessage, LoggerVerbosity expectedVerbosity, string verbosity = null, string logLevel = null, int expectedNumberOfWarnings = 0)
{
var provider = CreatePropertiesProvider(verbosity, logLevel);
TestLogger logger = new TestLogger();
var actualVerbosity = VerbosityCalculator.ComputeVerbosity(provider, logger);
Assert.AreEqual(expectedVerbosity, actualVerbosity, errorMessage);
logger.AssertErrorsLogged(0);
logger.AssertWarningsLogged(expectedNumberOfWarnings);
}
示例8: ConsoleLogger
/// <summary>
/// Create a logger instance with a specific verbosity. This logs to
/// the default console.
/// </summary>
/// <param name="verbosity">Verbosity level.</param>
public ConsoleLogger(LoggerVerbosity verbosity)
:
this
(
verbosity,
new WriteHandler(Console.Out.Write),
new ColorSetter(BaseConsoleLogger.SetColor),
new ColorResetter(BaseConsoleLogger.ResetColor)
)
{
// do nothing
}
示例9: Register
public static RegisterLoggerResult Register(
Guid loggerId,
LoggerVerbosity loggerVerbosity,
out BuildOutputLogger buildLogger)
{
try
{
const BindingFlags InterfacePropertyFlags = BindingFlags.GetProperty
| BindingFlags.Public
| BindingFlags.Instance;
BuildManager buildManager = BuildManager.DefaultBuildManager;
Type buildHostType = buildManager.GetType().Assembly.GetType("Microsoft.Build.BackEnd.IBuildComponentHost");
PropertyInfo loggingSeviceProperty = buildHostType.GetProperty("LoggingService", InterfacePropertyFlags);
object loggingServiceObj;
try
{
// Microsoft.Build.BackEnd.ILoggingService
loggingServiceObj = loggingSeviceProperty.GetValue(buildManager, null);
}
catch (TargetInvocationException ex)
{
ex.Trace("Microsoft.Build.BackEnd.ILoggingService is not available.");
buildLogger = null;
return RegisterLoggerResult.FatalError;
}
PropertyInfo loggersProperty = loggingServiceObj.GetType().GetProperty("Loggers", InterfacePropertyFlags);
ICollection<ILogger> loggers = (ICollection<ILogger>)loggersProperty.GetValue(loggingServiceObj, null);
ILogger logger = loggers.FirstOrDefault(x => x is BuildOutputLogger && ((BuildOutputLogger)x)._id.Equals(loggerId));
if (logger != null)
{
buildLogger = (BuildOutputLogger)logger;
buildLogger.Verbosity = loggerVerbosity;
return RegisterLoggerResult.AlreadyExists;
}
MethodInfo registerLoggerMethod = loggingServiceObj.GetType().GetMethod("RegisterLogger");
buildLogger = new BuildOutputLogger(loggerId) { Verbosity = loggerVerbosity };
bool registerResult = (bool)registerLoggerMethod.Invoke(loggingServiceObj, new object[] { buildLogger });
return registerResult ? RegisterLoggerResult.RegisterSuccess : RegisterLoggerResult.RegisterFailed;
}
catch (Exception ex)
{
ex.TraceUnknownException();
buildLogger = null;
return RegisterLoggerResult.FatalError;
}
}
示例10: ConsoleLogger
public ConsoleLogger (LoggerVerbosity verbosity, WriteHandler write, ColorSetter colorSet, ColorResetter colorReset)
{
if (write == null)
throw new ArgumentNullException ("write");
if (colorSet == null)
throw new ArgumentNullException ("colorSet");
if (colorReset == null)
throw new ArgumentNullException ("colorReset");
Verbosity = verbosity;
this.write = write;
set_color = colorSet;
reset_color = colorReset;
}
示例11: AssemblyLoadInfo
/// <summary>
/// Creates a logger description from given data
/// </summary>
public LoggerDescription
(
string loggerClassName,
string loggerAssemblyName,
string loggerAssemblyFile,
string loggerSwitchParameters,
LoggerVerbosity verbosity
)
{
this.loggerClassName = loggerClassName;
this.loggerAssembly = new AssemblyLoadInfo(loggerAssemblyName, loggerAssemblyFile);
this.loggerSwitchParameters = loggerSwitchParameters;
this.verbosity = verbosity;
}
示例12: LoggerDescription
public LoggerDescription (string loggerClassName, string loggerAssemblyName,
string loggerAssemblyFile, string loggerSwitchParameters,
LoggerVerbosity verbosity)
{
if (loggerAssemblyName != null && loggerAssemblyFile != null)
throw new InvalidOperationException ("Cannot specify both loggerAssemblyName and loggerAssemblyFile at the same time.");
if (loggerAssemblyName == null && loggerAssemblyFile == null)
throw new InvalidOperationException ("Either loggerAssemblyName or loggerAssemblyFile must be specified");
class_name = loggerClassName;
assembly_name = loggerAssemblyName;
assembly_file = loggerAssemblyFile;
LoggerSwitchParameters = loggerSwitchParameters;
Verbosity = verbosity;
}
示例13: Parameters
public Parameters ()
{
consoleLoggerParameters = "";
displayHelp = false;
loggers = new ArrayList ();
loggerVerbosity = LoggerVerbosity.Normal;
noConsoleLogger = false;
noLogo = false;
properties = new BuildPropertyGroup ();
targets = new string [0];
responseFile = Path.Combine (
Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location),
"xbuild.rsp");
}
示例14: BootstrapperSettings
public BootstrapperSettings(AnalysisPhase phase, IEnumerable<string> childCmdLineArgs, string sonarQubeUrl, LoggerVerbosity verbosity, ILogger logger)
{
if (sonarQubeUrl == null)
{
throw new ArgumentNullException("sonarQubeUrl");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
this.sonarQubeUrl = sonarQubeUrl;
this.analysisPhase = phase;
this.childCmdLineArgs = childCmdLineArgs;
this.verbosity = verbosity;
this.logger = logger;
}
示例15:
/// <summary>
/// Creates a logger description from given data
/// </summary>
public LoggerDescription
(
string loggerClassName,
string loggerAssemblyName,
string loggerAssemblyFile,
string loggerSwitchParameters,
LoggerVerbosity verbosity
)
{
_loggerClassName = loggerClassName;
if (loggerAssemblyFile != null && !Path.IsPathRooted(loggerAssemblyFile))
{
loggerAssemblyFile = FileUtilities.NormalizePath(loggerAssemblyFile);
}
_loggerAssembly = AssemblyLoadInfo.Create(loggerAssemblyName, loggerAssemblyFile);
_loggerSwitchParameters = loggerSwitchParameters;
_verbosity = verbosity;
}