当前位置: 首页>>代码示例>>C#>>正文


C# ILogger.DebugException方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:adbrowne,项目名称:EventStore,代码行数:26,代码来源:EsDriveInfo.cs

示例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;
            }
        }
开发者ID:robashton,项目名称:EventStore,代码行数:26,代码来源:EsDriveInfo.cs

示例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;
            }
        }
开发者ID:robashton,项目名称:EventStore,代码行数:25,代码来源:EsDriveInfo.cs


注:本文中的ILogger.DebugException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。