[tomboy/gnome-2-26] Add support for console logging on windows (in VS or from a cmd.exe), by attaching to the parent pro
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Subject: [tomboy/gnome-2-26] Add support for console logging on windows (in VS or from a cmd.exe), by attaching to the parent pro
- Date: Mon, 11 May 2009 10:15:33 -0400 (EDT)
commit 745ffc616ef3d9271ce031d4882b0d22983de46f
Author: Benjamin.Podszun <benjamin podszun gmail com>
Date: Wed Apr 29 17:06:01 2009 +0200
Add support for console logging on windows (in VS or from a cmd.exe), by attaching to the parent processes' console if possible
---
Tomboy/Logger.cs | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Tomboy/Logger.cs b/Tomboy/Logger.cs
index 24c5021..6cda0f4 100644
--- a/Tomboy/Logger.cs
+++ b/Tomboy/Logger.cs
@@ -19,6 +19,24 @@ namespace Tomboy
class ConsoleLogger : ILogger
{
+#if WIN32
+ [DllImport("kernel32.dll")]
+ public static extern bool AttachConsole (uint dwProcessId);
+ const uint ATTACH_PARENT_PROCESS = 0x0ffffffff;
+ [DllImport("kernel32.dll")]
+ public static extern bool FreeConsole ();
+
+ public ConsoleLogger ()
+ {
+ AttachConsole (ATTACH_PARENT_PROCESS);
+ }
+
+ ~ConsoleLogger ()
+ {
+ FreeConsole ();
+ }
+#endif
+
public void Log (Level lvl, string msg, params object[] args)
{
msg = string.Format ("[{0}]: {1}", Enum.GetName (typeof (Level), lvl), msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]