public static bool Execute() { string logfile = HugsLibUtility.TryGetLogFilePath(); if (logfile.NullOrEmpty() || !File.Exists(logfile)) { HugsLibController.Logger.ReportException(new FileNotFoundException("Log file path is unknown or log file does not exist. Path:" + logfile)); return(false); } var platform = PlatformUtility.GetCurrentPlatform(); switch (platform) { case PlatformType.Linux: return(Shell.StartProcess(new Shell.ShellCommand { FileName = logfile })); case PlatformType.MacOSX: return(Shell.StartProcess(new Shell.ShellCommand { FileName = "open", Args = logfile })); case PlatformType.Windows: return(Shell.StartProcess(new Shell.ShellCommand { FileName = logfile })); default: HugsLibController.Logger.ReportException(new Shell.UnsupportedPlatformException("ShellOpenLog")); return(false); } }
private string GetLogFileContents() { var filePath = HugsLibUtility.TryGetLogFilePath(); if (filePath.NullOrEmpty() || !File.Exists(filePath)) { throw new FileNotFoundException("Log file not found:" + filePath); } var tempPath = Path.GetTempFileName(); File.Delete(tempPath); // we need to copy the log file since the original is already opened for writing by Unity File.Copy(filePath, tempPath); var fileContents = File.ReadAllText(tempPath); File.Delete(tempPath); return("Log file contents:\n" + fileContents); }