本文整理汇总了C#中ILogger.Verbose方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.Verbose方法的具体用法?C# ILogger.Verbose怎么用?C# ILogger.Verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.Verbose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StratumMiner
/// <summary>
/// Creates a new miner instance.
/// </summary>
/// <param name="id"></param>
/// <param name="extraNonce"></param>
/// <param name="connection"></param>
/// <param name="pool"></param>
/// <param name="minerManager"></param>
/// <param name="storageLayer"></param>
public StratumMiner(int id, UInt32 extraNonce, IConnection connection, IPool pool, IMinerManager minerManager, IStorageLayer storageLayer)
{
Id = id; // the id of the miner.
ExtraNonce = extraNonce;
Connection = connection; // the underlying connection.
Pool = pool;
_minerManager = minerManager;
_storageLayer = storageLayer;
Subscribed = false; // miner has to subscribe.
Authenticated = false; // miner has to authenticate.
_logger = Log.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_packetLogger = LogManager.PacketLogger.ForContext<StratumMiner>().ForContext("Component", pool.Config.Coin.Name);
_rpcResultHandler = callback =>
{
var asyncData = ((JsonRpcStateAsync)callback); // get the async data.
var result = asyncData.Result + "\n"; // read the result.
var response = Encoding.UTF8.GetBytes(result); // set the response.
Connection.Send(response); // send the response.
_packetLogger.Verbose("tx: {0}", result.PrettifyJson());
};
}
示例2: NinjectCore
public NinjectCore(IKernel kernel, ILogger logger, ICoreSettings settings)
{
_kernel = kernel;
_logger = logger;
_settings = settings;
_logger.Information("Initializing Core.");
InitializeKernel();
InitializeExtensions();
_logger.Verbose("Core initilized.");
}
示例3: WebServer
public WebServer(INancyBootstrapper webBootstrapper, IConfigManager configManager)
: base(webBootstrapper)
{
var config = configManager.WebServerConfig;
BindIP = config.BindInterface;
Port = config.Port;
_logger = Log.ForContext<WebServer>();
if (config.Enabled)
Start();
else
_logger.Verbose("Skipping web-server initialization as it disabled.");
}
示例4: BluetoothProfileActivator
public BluetoothProfileActivator(IBluetoothService bluetoothService,
IPersonalizationSettings personalizationSettings,
ISchedulerProvider schedulerProvider,
ILoggerFactory loggerFactory)
{
_bluetoothService = bluetoothService;
_personalizationSettings = personalizationSettings;
_schedulerProvider = schedulerProvider;
_logger = loggerFactory.CreateLogger(GetType());
_bluetoothEventLoop = _schedulerProvider.CreateEventLoopScheduler("BluetoothActivator");
_logger.Verbose("BluetoothProfileActivator.ctor();");
_profileActivated = _bluetoothService.IdentitiesActivated(_bluetoothEventLoop)
.Retry()
.Repeat()
.Log(_logger, "IdentitiesActivated")
.Select(Translate)
.Publish();
//HACK: Avoid work in the ctor. Can be smart here using SelectMany on the IsEnabled + Connecting when ProfileActivated is subscribed to. -LC
if (_bluetoothService.IsSupported && IsEnabled)
_connection.Disposable = _profileActivated.Connect();
}
示例5: MigrateAssetIfNeeded
public static bool MigrateAssetIfNeeded(ILogger log, string assetFullPath)
{
// Determine if asset was Yaml or not
var assetFileExtension = Path.GetExtension(assetFullPath);
if (assetFileExtension == null)
return false;
assetFileExtension = assetFileExtension.ToLowerInvariant();
var serializer = AssetSerializer.FindSerializer(assetFileExtension);
if (!(serializer is AssetYamlSerializer))
return false;
// We've got a Yaml asset, let's get expected and serialized versions
var serializedVersion = 0;
int expectedVersion;
Type assetType;
// Read from Yaml file the asset version and its type (to get expected version)
// Note: It tries to read as few as possible (SerializedVersion is expected to be right after Id, so it shouldn't try to read further than that)
using (var streamReader = new StreamReader(assetFullPath))
{
var yamlEventReader = new EventReader(new Parser(streamReader));
// Skip header
yamlEventReader.Expect<StreamStart>();
yamlEventReader.Expect<DocumentStart>();
var mappingStart = yamlEventReader.Expect<MappingStart>();
var yamlSerializerSettings = YamlSerializer.GetSerializerSettings();
var tagTypeRegistry = yamlSerializerSettings.TagTypeRegistry;
assetType = tagTypeRegistry.TypeFromTag(mappingStart.Tag);
expectedVersion = AssetRegistry.GetCurrentFormatVersion(assetType);
Scalar assetKey;
while ((assetKey = yamlEventReader.Allow<Scalar>()) != null)
{
// Only allow Id before SerializedVersion
if (assetKey.Value == "Id")
{
yamlEventReader.Skip();
continue;
}
if (assetKey.Value == "SerializedVersion")
{
serializedVersion = Convert.ToInt32(yamlEventReader.Expect<Scalar>().Value, CultureInfo.InvariantCulture);
break;
}
}
}
if (serializedVersion > expectedVersion)
{
// Try to open an asset newer than what we support (probably generated by a newer Paradox)
throw new InvalidOperationException(string.Format("Asset of type {0} has been serialized with newer version {1}, but only version {2} is supported. Was this asset created with a newer version of Paradox?", assetType, serializedVersion, expectedVersion));
}
if (serializedVersion < expectedVersion)
{
// Perform asset upgrade
log.Verbose("{0} needs update, from version {1} to version {2}", Path.GetFullPath(assetFullPath), serializedVersion, expectedVersion);
// Load the asset as a YamlNode object
var input = new StringReader(File.ReadAllText(assetFullPath));
var yamlStream = new YamlStream();
yamlStream.Load(input);
var yamlRootNode = (YamlMappingNode)yamlStream.Documents[0].RootNode;
// Check if there is any asset updater
var assetUpgraders = AssetRegistry.GetAssetUpgraders(assetType);
if (assetUpgraders == null)
{
throw new InvalidOperationException(string.Format("Asset of type {0} should be updated from version {1} to {2}, but no asset migration path was found", assetType, serializedVersion, expectedVersion));
}
// Instantiate asset updaters
var currentVersion = serializedVersion;
while (currentVersion != expectedVersion)
{
int targetVersion;
// This will throw an exception if no upgrader is available for the given version, exiting the loop in case of error.
var upgrader = assetUpgraders.GetUpgrader(currentVersion, out targetVersion);
upgrader.Upgrade(currentVersion, targetVersion, log, yamlRootNode);
currentVersion = targetVersion;
}
// Make sure asset is updated to latest version
YamlNode serializedVersionNode;
var newSerializedVersion = 0;
if (yamlRootNode.Children.TryGetValue(new YamlScalarNode("SerializedVersion"), out serializedVersionNode))
{
newSerializedVersion = Convert.ToInt32(((YamlScalarNode)serializedVersionNode).Value);
}
if (newSerializedVersion != expectedVersion)
{
throw new InvalidOperationException(string.Format("Asset of type {0} was migrated, but still its new version {1} doesn't match expected version {2}.", assetType, newSerializedVersion, expectedVersion));
}
//.........这里部分代码省略.........
示例6: Log
protected override void Log(ILogger logger, string format, params object[] args)
{
logger.Verbose(format, args);
}
示例7: GetworkMiner
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="pool"></param>
/// <param name="minerManager"></param>
public GetworkMiner(int id, IPool pool, IMinerManager minerManager)
{
Id = id; // the id of the miner.
Pool = pool;
_minerManager = minerManager;
Authenticated = false; // miner has to authenticate.
Software = MinerSoftware.Unknown;
SoftwareVersion = new Version();
_logger = Log.ForContext<GetworkMiner>().ForContext("Component", pool.Config.Coin.Name);
_packetLogger = LogManager.PacketLogger.ForContext<GetworkMiner>().ForContext("Component", pool.Config.Coin.Name);
_rpcResultHandler = callback =>
{
var asyncData = ((JsonRpcStateAsync) callback);
var result = asyncData.Result;
var response = Encoding.UTF8.GetBytes(result);
var context = (GetworkContext) asyncData.AsyncState;
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.ContentLength64 = response.Length;
context.Response.OutputStream.Write(response, 0, response.Length);
_packetLogger.Verbose("tx: {0}", result.PrettifyJson());
};
}
示例8: CallService
//private async Task<ServiceDto> CallConsul(HttpContext context, ILogger log, string serviceName)
//{
// try
// {
// var data = new ServiceDto();
// log.Verbose("Searching service in Consul...");
// using (var client = new ConsulClient())
// {
// var consulCatalog = await client.Catalog.Service(serviceName);
// if (consulCatalog.Response.Length > 0)
// {
// var service = consulCatalog.Response[0];
// data.Address = IPAddress.Parse(service.Address);
// data.Port = service.ServicePort;
// log.Information("Sending request to {Host}:{port}...", service.Address, data.Port);
// }
// else
// {
// log.Warning("Service not found!");
// context.Response.Send(404);
// }
// }
// return data;
// }
// catch (Exception e)
// {
// log.Error(e, "Cannot call Consul");
// context.Response.Send(500);
// return null;
// }
//}
private static async Task CallService(HttpContext context, HttpRequest request, ILogger log, ServiceInfo serviceInfo)
{
IPAddress serviceAdress = IPAddress.Parse(serviceInfo.Address);
int servicePort = serviceInfo.Port;
using (context)
{
try
{
using (var client = new TcpClient())
{
client.Connect(serviceAdress, servicePort);
using (var realService = client.GetStream())
{
log.Verbose("Sending request...");
await request.RedirectToAsync(realService);
log.Verbose("Waiting response...");
await context.Response.RedirectFromAsync(realService);
log.Information("Finished!");
}
}
}
catch (Exception e)
{
log.Error(e, "Cannot call service");
context.Response.Send(500);
}
}
}
示例9: FileController
/// <summary>
/// Initializes a new instance of the <see cref="FileController"/> class.
/// </summary>
/// <param name="hostingEnvironment">
/// The hosting environment.
/// </param>
/// <param name="files">A list of files</param>
public FileController(IApplicationEnvironment hostingEnvironment)
{
log = Log.ForContext<FileController>();
fileUploadPath = Path.Combine(hostingEnvironment.ApplicationBasePath, "Uploads");
log.Verbose("File handler created with base path: {@basepath}", fileUploadPath);
}