本文整理汇总了C#中ILogger.DebugException方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.DebugException方法的具体用法?C# ILogger.DebugException怎么用?C# ILogger.DebugException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.DebugException方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectoryRootInUnix
private static string GetDirectoryRootInUnix(string directory, ILogger log)
{
// http://unix.stackexchange.com/questions/11311/how-do-i-find-on-which-physical-device-a-folder-is-located
// example
// Filesystem 1K-blocks Used Available Use% Mounted on
// /dev/sda1 153599996 118777100 34822896 78% /media/CC88FD3288FD1C20
try
{
if(!Directory.Exists(directory)) return null;
var driveInfo = ShellExecutor.GetOutput("df", string.Format("-P {0}", directory));
var driveInfoLines = driveInfo.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
if(driveInfoLines.Length == 0) return null;
var ourline = driveInfoLines[1];
var trimmedLine = SystemStatsHelper.SpacesRegex.Replace(ourline, " ");
var driveName = trimmedLine.Split(' ')[5]; //we choose the 'mounted on' column
return driveName;
}
catch (Exception ex)
{
log.DebugException(ex, "Couldn't get drive name for directory '{0}' on Unix.", directory);
return null;
}
}
示例2: FromDirectory
public static EsDriveInfo FromDirectory(string path, ILogger log)
{
try
{
string driveName;
if (OS.IsLinux)
{
driveName = GetDirectoryRootInLinux(path, log);
if (driveName == null)
return null;
}
else
{
driveName = Directory.GetDirectoryRoot(path);
}
var drive = new DriveInfo(driveName);
var esDrive = new EsDriveInfo(drive.Name, drive.TotalSize, drive.AvailableFreeSpace);
return esDrive;
}
catch (Exception ex)
{
log.DebugException(ex, "Error while reading drive info for path {0}", path);
return null;
}
}
示例3: GetDirectoryRootInLinux
private static string GetDirectoryRootInLinux(string directory, ILogger log)
{
// http://unix.stackexchange.com/questions/11311/how-do-i-find-on-which-physical-device-a-folder-is-located
// example
// Filesystem 1K-blocks Used Available Use% Mounted on
// /dev/sda1 153599996 118777100 34822896 78% /media/CC88FD3288FD1C20
try
{
var driveInfo = ShellExecutor.GetOutput("df", directory);
var driveInfoLines = driveInfo.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
var ourline = driveInfoLines[1];
var spaces = new Regex(@"[\s\t]+", RegexOptions.Compiled);
var trimmedLine = spaces.Replace(ourline, " ");
var driveName = trimmedLine.Split(' ')[5]; //we choose the 'mounted on' column
return driveName;
}
catch (Exception ex)
{
log.DebugException(ex, "couldn't get drive name for directory {0} on linux", directory);
return null;
}
}