aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Logging/LogManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging/LogManager.cs')
-rw-r--r--Software/Visual_Studio/Tango.Logging/LogManager.cs55
1 files changed, 30 insertions, 25 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs
index ba73b32b4..98bcaaa28 100644
--- a/Software/Visual_Studio/Tango.Logging/LogManager.cs
+++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs
@@ -124,7 +124,6 @@ namespace Tango.Logging
log.Exception = e;
log.Category = category;
log.Description = description;
- log.Message = log.Description + Environment.NewLine + log.Exception.FlattenException();
AppendLog(log);
@@ -132,6 +131,25 @@ namespace Tango.Logging
}
/// <summary>
+ /// Add new exception log item.
+ /// </summary>
+ /// <param name="e">Exception.</param>
+ /// <param name="description">Error description.</param>
+ public Exception LogFormat(Exception e, String description, object argument, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0)
+ {
+ return Log(e, LogCategory.Error, String.Format(description, argument), caller, file, lineNumber);
+ }
+
+ /// <summary>
+ /// Add new message log item.
+ /// </summary>
+ /// <param name="message">Message.</param>
+ public String LogFormat(String message, object argument, [CallerMemberName] string caller = null, [CallerFilePath] string file = null, [CallerLineNumber] int lineNumber = 0)
+ {
+ return Log(String.Format(message, argument), LogCategory.Info, null, caller, file, lineNumber);
+ }
+
+ /// <summary>
/// Add new message log item.
/// </summary>
/// <param name="message">Message.</param>
@@ -187,24 +205,20 @@ namespace Tango.Logging
{
String log = "--------------------- Referenced Assemblies --------------------------" + Environment.NewLine + Environment.NewLine;
- try
- {
- string codeBase = typeof(LogManager).Assembly.CodeBase;
- UriBuilder uri = new UriBuilder(codeBase);
- string path = Uri.UnescapeDataString(uri.Path);
- String folder = Path.GetDirectoryName(path);
+ string codeBase = typeof(LogManager).Assembly.CodeBase;
+ UriBuilder uri = new UriBuilder(codeBase);
+ string path = Uri.UnescapeDataString(uri.Path);
+ String folder = Path.GetDirectoryName(path);
- foreach (var file in Directory.GetFiles(folder, "*.dll"))
- {
- FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(file);
- string version = fvi.ProductVersion;
- log += Path.GetFileNameWithoutExtension(file) + ", v" + version + Environment.NewLine;
- }
+ foreach (var file in Directory.GetFiles(folder, "*.dll"))
+ {
+ FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(file);
+ string version = fvi.ProductVersion;
+ log += Path.GetFileNameWithoutExtension(file) + ", v" + version + Environment.NewLine;
+ }
- log += Environment.NewLine + "--------------------- --------------------- --------------------------";
+ log += Environment.NewLine + "--------------------- --------------------- --------------------------";
- }
- catch { }
Log(log);
}
@@ -257,14 +271,5 @@ namespace Tango.Logging
NewLog?.Invoke(this, log);
}
}
-
- /// <summary>
- /// Creates a new log safe which can be used to keep logs and then be disposed.
- /// </summary>
- /// <returns></returns>
- public LogSafe CreateLogSafe()
- {
- return new LogSafe(this);
- }
}
}