public void Write(object msg, string typ = "DBG", [CallerMemberName] string method = null, [CallerFilePath] string filepath = null, [CallerLineNumber] int line = 0) { var threadID = UiDispatcher.Thread == Thread.CurrentThread ? "[ UI ]" : $"[{Thread.CurrentThread.ManagedThreadId,4}]"; var codeIdentifier = new CodePosition(method, filepath, line).GetIdentifier(24).Expand(24); typ = typ.Cut(3, "").Expand(3); var prefix = $"{typ} {DateTime.Now:mm:ss.fff} {threadID}-> {codeIdentifier} :: "; var message = msg == null ? "null" : msg is string ? msg as string : msg.ToString(); var lines = message.Split("\r\n").ToList(); var firstline = lines[0]; lines.RemoveAt(0); if (lines.Count == 0) { Debug.WriteLine(prefix + firstline); } else { var restlines = lines.Select(x => " ".Expand(prefix.Length) + x).Join("\r\n"); Debug.WriteLine(prefix + firstline + "\r\n" + restlines); } }
internal CsMessage(Types type, object content, string title, MessageButtons button, [CallerMemberName] string methodName = null, [CallerFilePath] string classFilePath = null, [CallerLineNumber] int classLineNumber = 0) { _time = DateTime.Now; _type = type; _content = content; _title = title; _messageButton = button; _code = new CodePosition(methodName, classFilePath, classLineNumber); _messageId = SmallHash.FromString(_content.ToString()); _iD = SmallHash.FromString(new[] {Code.PositionId, MessageId}.Join("")); }
public void Track(string name = null, [CallerMemberName] string method = null, [CallerFilePath] string filepath = null, [CallerLineNumber] int line = 0) { lock (_trackcounter) { var threadID = UiDispatcher.Thread == Thread.CurrentThread ? "-UI-" : $"{Thread.CurrentThread.ManagedThreadId,4}"; var identifier = new CodePosition(filepath, method, line).GetIdentifier(24).Expand(24); var count = 1; if (_trackcounter.ContainsKey(identifier)) { count = _trackcounter[identifier] + 1; _trackcounter[identifier] = count; } else { _trackcounter.Add(identifier, count); } Debug.WriteLine((name ?? identifier) + " => Count:" + count.ToString(CultureInfo.InvariantCulture).Expand(5, " ", true) + " Thread: " + threadID); } }