Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        private void OnReceived(TraceEvent value)
        {
            if (m_Filter != null && !m_Filter(value))
            {
                return;
            }

            try
            {
                if (MaxTraceEventCount > 0)
                {
                    AddTraceEvent(value);
                }

                OnReceivedLog?.Invoke(value);

                if (Received != null)
                {
                    OnReceived(new TraceEventArgs(value));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 2
0
        private static void Output(string _format, params object[] _args)
        {
            string prefix = "";

            if (ShowCallerInLog)
            {
                StackFrame frame         = new StackFrame(2, true);
                var        method        = frame.GetMethod();
                var        declaringType = method.DeclaringType.Name;
                if (declaringType.StartsWith("<>"))
                {
                    declaringType = method.DeclaringType.DeclaringType.Name;
                }
                prefix = $"[{declaringType}.{method}]";
            }
            string line = string.Format($"[{DateTime.Now:HH:mm:ss fff}]{prefix}: " + _format, _args);

            Console.WriteLine(line);
            OnReceivedLog?.Invoke(line);
            if (IsOutputToFile)
            {
                File.AppendAllText(OutputPath, "\n" + line);
            }
        }