本文整理汇总了C#中ILogger.LogVerbose方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.LogVerbose方法的具体用法?C# ILogger.LogVerbose怎么用?C# ILogger.LogVerbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.LogVerbose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Route
public static void Route(ILogger logger, string msg)
{
if (!msg.IsNullOrEmpty())
{
if (msg.StartsWith(StartVerbose))
_isVerboseMode = true;
else if (msg.StartsWith(StopVerbose))
_isVerboseMode = false;
else
{
if (msg.StartsWith(Verbose))
logger.LogVerbose(msg.Substring(Verbose.Length));
else if (msg.StartsWith(Success))
logger.LogSuccess(msg.Substring(Success.Length));
else if (msg.StartsWith(Warning))
logger.LogWarning(msg.Substring(Warning.Length));
else if (msg.StartsWith(Error))
logger.LogError(msg.Substring(Error.Length));
else if (msg.StartsWith(Header))
{
_isVerboseMode = false;
logger.LogHeader(msg.Substring(Header.Length));
}
else if (_isVerboseMode)
logger.LogVerbose(msg);
else
logger.LogInfo(msg);
}
}
else
{
//logger.LogInfo(msg);
}
}
示例2: Match
public static bool Match(IReadOnlyDictionary<string, IRouteConstraint> constraints,
IDictionary<string, object> routeValues,
HttpContext httpContext,
IRouter route,
RouteDirection routeDirection,
ILogger logger)
{
if (routeValues == null)
{
throw new ArgumentNullException(nameof(routeValues));
}
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
if (route == null)
{
throw new ArgumentNullException(nameof(route));
}
if (logger == null)
{
throw new ArgumentNullException(nameof(logger));
}
if (constraints == null)
{
return true;
}
foreach (var kvp in constraints)
{
var constraint = kvp.Value;
if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection))
{
if (routeDirection.Equals(RouteDirection.IncomingRequest))
{
object routeValue;
routeValues.TryGetValue(kvp.Key, out routeValue);
logger.LogVerbose(
"Route value '{RouteValue}' with key '{RouteKey}' did not match " +
"the constraint '{RouteConstraint}'.",
routeValue,
kvp.Key,
kvp.Value);
}
return false;
}
}
return true;
}
示例3: Configure
public static void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger("main");
logger.LogVerbose("Configure");
app.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest) await InitConnection(context);
else await next();
});
}
示例4: Configure
public static void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IConfigurationRoot config)
{
logger = loggerFactory.CreateLogger("BaseHub");
logger.LogVerbose("Configure");
if (_dal == null)
{
var hostName = config["Data:DbConnection:Hostname"];
var dbName = config["Data:DbConnection:DbName"];
_dal = new BaseDAL(hostName, dbName);
var connectionRetult = _dal.InitConnection();
logger.LogVerbose("connectionRetult=" + connectionRetult);
}
app.UseWebSockets(new WebSocketOptions() { ReplaceFeature = true });
app.Use(async (context, next) =>
{
if (context.WebSockets.IsWebSocketRequest) await InitConnection(context);
else await next();
});
}
示例5: GetAsync
public static async Task<HttpResponseMessage> GetAsync(this HttpClient httpClient, string requestUri,
ILogger logger)
{
if (logger == null)
{
return await httpClient.GetAsync(requestUri);
}
logger.LogVerbose($"Sending request {requestUri}");
var now = DateTimeOffset.Now;
var res = await httpClient.GetAsync(requestUri).ConfigureAwait(false);
if (res.IsSuccessStatusCode)
{
logger.LogVerbose(
$"Got response {res.StatusCode} in {(DateTimeOffset.Now - now).TotalMilliseconds.ToString("F2")}ms");
}
else
{
logger.LogError(
$"Got response {res.StatusCode} in {(DateTimeOffset.Now - now).TotalMilliseconds.ToString("F2")}ms");
}
return res;
}
示例6: FromBytes
public static RedisMessage FromBytes(byte[] data, ILogger logger)
{
using (var stream = new MemoryStream(data))
{
var message = new RedisMessage();
// read message id from memory stream until SPACE character
var messageIdBuilder = new StringBuilder(20);
do
{
// it is safe to read digits as bytes because they encoded by single byte in UTF-8
int charCode = stream.ReadByte();
if (charCode == -1)
{
logger.LogVerbose("Received Message could not be parsed.");
throw new EndOfStreamException();
}
char c = (char)charCode;
if (c == ' ')
{
message.Id = ulong.Parse(messageIdBuilder.ToString(), CultureInfo.InvariantCulture);
messageIdBuilder = null;
}
else
{
messageIdBuilder.Append(c);
}
}
while (messageIdBuilder != null);
var binaryReader = new BinaryReader(stream);
int count = binaryReader.ReadInt32();
byte[] buffer = binaryReader.ReadBytes(count);
message.ScaleoutMessage = ScaleoutMessage.FromBytes(buffer);
return message;
}
}
示例7: Main
public int Main(string[] args)
{
#if DEBUG
if (args.Contains("--debug"))
{
args = args.Skip(1).ToArray();
System.Diagnostics.Debugger.Launch();
}
#endif
// Set up logging
_log = new CommandOutputLogger();
var app = new CommandLineApplication();
app.Name = "nuget3";
app.FullName = ".NET Package Manager";
app.HelpOption("-h|--help");
app.VersionOption("--version", GetType().GetTypeInfo().Assembly.GetName().Version.ToString());
app.Command("restore", restore =>
{
restore.Description = "Restores packages for a project and writes a lock file";
var sources = restore.Option("-s|--source <source>", "Specifies a NuGet package source to use during the restore", CommandOptionType.MultipleValue);
var packagesDirectory = restore.Option("--packages <packagesDirectory>", "Directory to install packages in", CommandOptionType.SingleValue);
var parallel = restore.Option("-p|--parallel <noneOrNumberOfParallelTasks>", $"The number of concurrent tasks to use when restoring. Defaults to {RestoreRequest.DefaultDegreeOfConcurrency}; pass 'none' to run without concurrency.", CommandOptionType.SingleValue);
var projectFile = restore.Argument("[project file]", "The path to the project to restore for, either a project.json or the directory containing it. Defaults to the current directory");
restore.OnExecute(async () =>
{
// Figure out the project directory
IEnumerable<string> externalProjects = null;
PackageSpec project;
var projectPath = Path.GetFullPath(projectFile.Value ?? ".");
if (string.Equals(PackageSpec.PackageSpecFileName, Path.GetFileName(projectPath), StringComparison.OrdinalIgnoreCase))
{
_log.LogVerbose($"Reading project file {projectFile.Value}");
projectPath = Path.GetDirectoryName(projectPath);
project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(projectFile.Value), Path.GetFileName(projectPath), projectFile.Value);
}
else if (MsBuildUtility.IsMsBuildBasedProject(projectPath))
{
#if DNXCORE50
throw new NotSupportedException();
#else
externalProjects = MsBuildUtility.GetProjectReferences(projectPath);
projectPath = Path.GetDirectoryName(Path.GetFullPath(projectPath));
var packageSpecFile = Path.Combine(projectPath, PackageSpec.PackageSpecFileName);
project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(packageSpecFile), Path.GetFileName(projectPath), projectFile.Value);
_log.LogVerbose($"Reading project file {projectFile.Value}");
#endif
}
else
{
var file = Path.Combine(projectPath, PackageSpec.PackageSpecFileName);
_log.LogVerbose($"Reading project file {file}");
project = JsonPackageSpecReader.GetPackageSpec(File.ReadAllText(file), Path.GetFileName(projectPath), file);
}
_log.LogVerbose($"Loaded project {project.Name} from {project.FilePath}");
// Resolve the root directory
var rootDirectory = PackageSpecResolver.ResolveRootDirectory(projectPath);
_log.LogVerbose($"Found project root directory: {rootDirectory}");
// Resolve the packages directory
var packagesDir = packagesDirectory.HasValue() ?
packagesDirectory.Value() :
Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), ".nuget", "packages");
_log.LogVerbose($"Using packages directory: {packagesDir}");
var packageSources = sources.Values.Select(s => new PackageSource(s));
if (!packageSources.Any())
{
var settings = Settings.LoadDefaultSettings(projectPath,
configFileName: null,
machineWideSettings: null);
var packageSourceProvider = new PackageSourceProvider(settings);
packageSources = packageSourceProvider.LoadPackageSources();
}
var request = new RestoreRequest(
project,
packageSources,
packagesDir);
if (externalProjects != null)
{
foreach (var externalReference in externalProjects)
{
request.ExternalProjects.Add(
new ExternalProjectReference(
externalReference,
Path.Combine(Path.GetDirectoryName(externalReference), PackageSpec.PackageSpecFileName),
projectReferences: Enumerable.Empty<string>()));
}
}
//.........这里部分代码省略.........
示例8: ShouldDisplayErrorPage
private static bool ShouldDisplayErrorPage(DataStoreErrorLogger.DataStoreErrorLog lastError, Exception exception, ILogger logger)
{
logger.LogVerbose(Strings.FormatDatabaseErrorPage_AttemptingToMatchException(exception.GetType()));
if (!lastError.IsErrorLogged)
{
logger.LogVerbose(Strings.DatabaseErrorPage_NoRecordedException);
return false;
}
bool match = false;
for (var e = exception; e != null && !match; e = e.InnerException)
{
match = lastError.Exception == e;
}
if (!match)
{
logger.LogVerbose(Strings.DatabaseErrorPage_NoMatch);
return false;
}
logger.LogVerbose(Strings.DatabaseErrorPage_Matched);
return true;
}
示例9: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
log("Configure");
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
_logger = loggerFactory.CreateLogger("mw5");
_logger.LogInformation("DataFolder = " + _DataFolder);
app.UseIISPlatformHandler();
// Register a simple error handler to catch token expiries and change them to a 401,
// and return all other errors as a 500. This should almost certainly be improved for
// a real application.
app.UseExceptionHandler(appBuilder =>
{
appBuilder.Use(async (context, next) =>
{
var error = context.Features[typeof(IExceptionHandlerFeature)] as IExceptionHandlerFeature;
// This should be much more intelligent - at the moment only expired
// security tokens are caught - might be worth checking other possible
// exceptions such as an invalid signature.
if (error != null && error.Error is SecurityTokenExpiredException)
{
context.Response.StatusCode = 401;
// What you choose to return here is up to you, in this case a simple
// bit of JSON to say you're no longer authenticated.
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(
JsonConvert.SerializeObject(
new { authenticated = false, tokenExpired = true }));
}
else if (error != null && error.Error != null)
{
context.Response.StatusCode = 500;
context.Response.ContentType = "application/json";
// TODO: Shouldn't pass the exception message straight out, change this.
await context.Response.WriteAsync(
JsonConvert.SerializeObject
(new { success = false, error = error.Error.Message }));
}
// We're not trying to handle anything else so just let the default
// handler handle.
else await next();
});
});
app.UseStaticFiles();
app.UseMvc();
bool CreateInitialData = false;
if (CreateInitialData)
{
_logger.LogVerbose("start creating initial data");
SampleData sd = new SampleData(_logger);
sd.Initialize(app.ApplicationServices);
_logger.LogVerbose("initial data created");
}
}
示例10: LoadTemplate
public static ReportTemplate LoadTemplate(ReportType reportType, ILogger logger)
{
logger.LogVerbose(Message.Common_DebugCall);
const string REPORTTEMPLATE_FILEPATH_FORMAT = "./Data/Templates/{0}.xml";
const string REPORTTEMPLATE_SCHEMA_FILEPATH = "./Data/Schemas/ReportTemplate.xsd";
const string REPORTTEMPLATE_SCHEMA_URL = "http://localhost/Schemas/SIB2003/ReportTemplate";
var templatePath = new FileInfo(string.Format(REPORTTEMPLATE_FILEPATH_FORMAT, reportType));
if (!templatePath.Exists)
{
logger.LogError(Message.PrintingReportTemplateNotFound, reportType);
throw new Exception("Не найден шаблон: " + reportType);
}
try
{
var doc = new XmlDocument();
doc.Load(templatePath.FullName);
var xmlSettings = new XmlReaderSettings();
xmlSettings.Schemas.Add(REPORTTEMPLATE_SCHEMA_URL, REPORTTEMPLATE_SCHEMA_FILEPATH);
xmlSettings.ValidationEventHandler +=
(sender, args) => logger.LogError(
Message.PrintingReportTemplateValidationError,
args.Exception,
reportType);
var xmlTextReader = new XmlTextReader(doc.InnerXml, XmlNodeType.Document, null);
var xmlReader = XmlReader.Create(xmlTextReader, xmlSettings);
var oSerializer = new XmlSerializer(typeof(ReportTemplate), REPORTTEMPLATE_SCHEMA_URL);
logger.LogVerbose(Message.Common_DebugReturn);
return (ReportTemplate)oSerializer.Deserialize(xmlReader);
}
catch (Exception ex)
{
logger.LogError(Message.PrintingLoadReportTemplateFailed, ex, reportType);
throw;
}
}