aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Logging/LogManager.cs
diff options
context:
space:
mode:
authorMirta <mirta@twine-s.com>2020-12-30 14:27:05 +0200
committerMirta <mirta@twine-s.com>2020-12-30 14:27:05 +0200
commit1344a54c37f7cbba7a294674b4b733d72ee257ea (patch)
tree4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.Logging/LogManager.cs
parent124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff)
parent281610ac56799f6870c587a942495d91cd55b227 (diff)
downloadTango-1344a54c.tar.gz
Tango-1344a54c.zip
Hope it is fine
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);
- }
}
}