Skip to content

Commit ec6e46b

Browse files
committed
NuGet v1.0.9, better support for apps with no console
1 parent 3b0d74a commit ec6e46b

42 files changed

Lines changed: 69 additions & 16 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vs/SyslogLogging/v14/.suo

-512 Bytes
Binary file not shown.

.vs/SyslogLogging/v15/.suo

81 KB
Binary file not shown.

LoggingModule/LoggingModule.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public LoggingModule(
7777
IncludeThreadId = includeThreadId;
7878
IndentByStackSize = indentByStackSize;
7979

80+
if (!ConsoleExists() && ConsoleEnable)
81+
{
82+
Debug.WriteLine("Console logging disabled (console does not exist)");
83+
ConsoleEnable = false;
84+
}
85+
8086
if (!String.IsNullOrEmpty(SyslogServerIp) && SyslogServerPort > 0)
8187
{
8288
try
@@ -85,14 +91,14 @@ public LoggingModule(
8591
}
8692
catch (Exception e)
8793
{
88-
Console.WriteLine("---");
89-
Console.WriteLine("");
90-
Console.WriteLine("NOTICE:");
91-
Console.WriteLine("");
92-
Console.WriteLine("Exception while initializing UDP syslog client: " + e.Message);
93-
Console.WriteLine("Syslog logging to server " + SyslogServerIp + ":" + SyslogServerPort + " is DISABLED as a result");
94-
Console.WriteLine("");
95-
Console.WriteLine("---");
94+
Debug.WriteLine("---");
95+
Debug.WriteLine("");
96+
Debug.WriteLine("NOTICE:");
97+
Debug.WriteLine("");
98+
Debug.WriteLine("Exception while initializing UDP syslog client: " + e.Message);
99+
Debug.WriteLine("Syslog logging to server " + SyslogServerIp + ":" + SyslogServerPort + " is DISABLED as a result");
100+
Debug.WriteLine("");
101+
Debug.WriteLine("---");
96102
UDP = null;
97103
}
98104
}
@@ -253,6 +259,18 @@ public static void ConsoleException(string module, string method, Exception e)
253259

254260
#region Private-Methods
255261

262+
private bool ConsoleExists()
263+
{
264+
try
265+
{
266+
return (Console.WindowHeight > 0);
267+
}
268+
catch (Exception)
269+
{
270+
return false;
271+
}
272+
}
273+
256274
private void SendToConsole(string msg)
257275
{
258276
if (String.IsNullOrEmpty(msg)) return;
@@ -279,7 +297,7 @@ private void SendToSyslog(string msg)
279297
}
280298
catch (Exception e)
281299
{
282-
Console.WriteLine("Exception while sending to syslog server " + SyslogServerIp + ":" + SyslogServerPort + ", disabling: " + e.Message);
300+
Debug.WriteLine("Exception while sending to syslog server " + SyslogServerIp + ":" + SyslogServerPort + ", disabling: " + e.Message);
283301
UDP = null;
284302
}
285303
}

LoggingModule/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("Marauder Software Inc")]
1212
[assembly: AssemblyProduct("SyslogLogging")]
13-
[assembly: AssemblyCopyright("Copyright (c)2016 Marauder Software Inc")]
13+
[assembly: AssemblyCopyright("Copyright (c)2017 Marauder Software Inc")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.8.0")]
36-
[assembly: AssemblyFileVersion("1.0.8.0")]
35+
[assembly: AssemblyVersion("1.0.9.0")]
36+
[assembly: AssemblyFileVersion("1.0.9.0")]
512 Bytes
Binary file not shown.
2 KB
Binary file not shown.
-512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0ea76295e869dfb6bd7727a4ab25ef0a5f49ac26
Binary file not shown.

0 commit comments

Comments
 (0)