Cosmos/source2/VSIP/Cosmos.VS.Package/LogUtility.cs
BlueSkeye_cp 7372c8a9bd Bochs integration : alpha version
Limitations :

- Bochs must be installed on the system. This is not checked as a  prerequisite by the Builder.
- You will find a GuessForBochs Cosmos project under BlueSkeye user project folder that can be used to launch the Guess project under Bochs.
- You may have to fix manually the path for the following properties in Cosmos.bxrc file copied to the CosmosForBochs\Bin\Debug folder
  * romimage
  * vgaromimage
- The Cosmos project UI is not yet Bochs aware. If you do not use the GuessForBochs project you must manually edit your Cosmos project file to modify the following property in both the Debug and Release property group from the project file :

    <Launch>Bochs</Launch>

  You must also add the following properties in both the Debug and Release property group from the project file :

    <BochsConfig>Cosmos.bxrc</BochsConfig>
    <Bochs_Deployment>ISO</Bochs_Deployment>
    <Bochs_Launch>Bochs</Bochs_Launch>
    <Bochs_DebugEnabled>True</Bochs_DebugEnabled>
    <Bochs_DebugMode>Source</Bochs_DebugMode>
    <Bochs_IgnoreDebugStubAttribute />
    <Bochs_VMwareEdition>Player</Bochs_VMwareEdition>
    <Bochs_OutputPath>bin\Debug\</Bochs_OutputPath>
    <Bochs_Framework>MicrosoftNET</Bochs_Framework>
    <Bochs_UseInternalAssembler>False</Bochs_UseInternalAssembler>
    <Bochs_TraceAssemblies />
    <Bochs_EnableGDB>False</Bochs_EnableGDB>
    <Bochs_StartCosmosGDB>false</Bochs_StartCosmosGDB>
    <Bochs_Name>GuessForBochs</Bochs_Name>
    <Bochs_Description>Use Bochs emulator to deploy and debug.</Bochs_Description>
    <Bochs_VisualStudioDebugPort>Pipe: Cosmos\Serial</Bochs_VisualStudioDebugPort>
    <Bochs_PxeInterface>192.168.43.1</Bochs_PxeInterface>
    <Bochs_SlavePort>Serial: COM3</Bochs_SlavePort>
    <Bochs_ShowLaunchConsole>False</Bochs_ShowLaunchConsole>
2012-09-14 17:13:06 +00:00

60 lines
1.9 KiB
C#

#define FULL_DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Cosmos.VS.Package
{
public static class LogUtility
{
private static readonly object mLockObj = new object();
[Conditional("FULL_DEBUG")]
public static void LogString(string message, params object[] args)
{
#if FULL_DEBUG
lock (mLockObj)
{
File.AppendAllText(GetLogFilePath(), DateTime.Now.ToString() + " - " + String.Format(message, args) + "\r\n");
}
#endif
}
public static void LogException(Exception e, bool dontThrow = false)
{
#if FULL_DEBUG
if (null != e) {
do {
LogString("Error : {0}", e.Message);
LogString("Stack : {0}", e.StackTrace);
e = e.InnerException;
} while (null != e);
}
#endif
if (!dontThrow) { throw new Exception("Error occurred", e); }
}
private static string _logFilePath;
private static string GetLogFilePath()
{
if (null != _logFilePath) { return _logFilePath; }
_logFilePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Cosmos", "CosmosPkg.log");
Stack<DirectoryInfo> missingDirectories = new Stack<DirectoryInfo>();
DirectoryInfo scannedDirectory = new FileInfo(_logFilePath).Directory;
while (!scannedDirectory.Exists) {
missingDirectories.Push(scannedDirectory);
scannedDirectory = scannedDirectory.Parent;
}
while (0 < missingDirectories.Count) {
try { Directory.CreateDirectory(missingDirectories.Pop().FullName); }
catch { break; }
}
return _logFilePath;
}
}
}