mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
LogWriter: Minor improvements
This commit is contained in:
parent
359cf7a54c
commit
cceae3adf5
1 changed files with 17 additions and 11 deletions
|
@ -21,16 +21,7 @@ namespace SMBServer
|
||||||
|
|
||||||
public LogWriter()
|
public LogWriter()
|
||||||
{
|
{
|
||||||
Assembly assembly = Assembly.GetEntryAssembly();
|
string assemblyDirectory = GetAssemblyDirectory();
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
assembly = Assembly.GetExecutingAssembly();
|
|
||||||
}
|
|
||||||
string assemblyDirectory = Path.GetDirectoryName(assembly.Location);
|
|
||||||
if (!assemblyDirectory.EndsWith(@"\"))
|
|
||||||
{
|
|
||||||
assemblyDirectory += @"\";
|
|
||||||
}
|
|
||||||
m_logsDirectoryPath = assemblyDirectory + @"Logs\";
|
m_logsDirectoryPath = assemblyDirectory + @"Logs\";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +94,24 @@ namespace SMBServer
|
||||||
{
|
{
|
||||||
if (entry.Severity != Severity.Trace)
|
if (entry.Severity != Severity.Trace)
|
||||||
{
|
{
|
||||||
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ");
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
WriteLine("{0} {1} [{2}] {3}", entry.Severity.ToString().PadRight(12), timestamp, entry.Source, entry.Message);
|
WriteLine("{0} {1} [{2}] {3}", entry.Severity.ToString().PadRight(12), timestamp, entry.Source, entry.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetAssemblyDirectory()
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.GetEntryAssembly();
|
||||||
|
if (assembly == null)
|
||||||
|
{
|
||||||
|
assembly = Assembly.GetExecutingAssembly();
|
||||||
|
}
|
||||||
|
string assemblyDirectory = Path.GetDirectoryName(assembly.Location);
|
||||||
|
if (!assemblyDirectory.EndsWith(@"\"))
|
||||||
|
{
|
||||||
|
assemblyDirectory += @"\";
|
||||||
|
}
|
||||||
|
return assemblyDirectory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue