Exemplo n.º 1
0
        public void OnInvoke(CInjection injection)
        {
            try
            {
                _context = _tracingContext.CreateEntrySegmentContext(injection.Method.Name, new TextCarrierHeaderCollection(new Dictionary <string, string>()));

                _injection = injection;
                _startTime = DateTime.Now;

                if (!Logger.IsDebugEnabled)
                {
                    return;
                }
                if (_injection == null)
                {
                    return;
                }
                if (!File.Exists(FileName))
                {
                    return;
                }
                if (!injection.IsValid())
                {
                    return;
                }

                var objectSearch = CachedSerializer.Deserialize <ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);
                if (objectSearch == null || objectSearch.PropertyNames == null)
                {
                    return;
                }

                _context.Span.AddTag("Method", injection.Method.Name);
                foreach (string propertyName in objectSearch.PropertyNames)
                {
                    var dictionary = _injection.GetPropertyValue(propertyName);
                    var method     = "";
                    var value      = "";
                    foreach (var key in dictionary.Keys)
                    {
                        method = string.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>");
                        Logger.Debug(method);

                        value += propertyName + "=" + dictionary[key] ?? "<null> /r/n ";
                    }

                    _context.Span.AddLog(LogEvent.Event($"{injection.Method.Name} :{value}"));
                }
            }
            catch (Exception ex)
            {
                Logger.Debug("OnInvoke ex:" + ex.Message);
                Logger.Error(ex);
            }
        }
Exemplo n.º 2
0
        private string GetStringValue(object input)
        {
            if (input == null)
            {
                return("null");
            }

            try
            {
                return(CachedSerializer.Serialize(input.GetType(), input, Encoding.UTF8));
            }
            catch // can not serialize, then call ToString() method.
            {
                return(input.ToString());
            }
        }
Exemplo n.º 3
0
        public void OnInvoke(CInjection injection)
        {
            _injection = injection;


            if (!Logger.IsDebugEnabled)
            {
                return;
            }
            if (_injection == null)
            {
                return;
            }
            if (!File.Exists(FileName))
            {
                return;
            }
            if (!injection.IsValid())
            {
                return;
            }

            var objectSearch = CachedSerializer.Deserialize <ObjectSearch>(File.ReadAllText(FileName), Encoding.UTF8);

            if (objectSearch == null || objectSearch.PropertyNames == null)
            {
                return;
            }

            foreach (string propertyName in objectSearch.PropertyNames)
            {
                var dictionary = _injection.GetPropertyValue(propertyName);

                foreach (var key in dictionary.Keys)
                {
                    Logger.Debug(String.Format("Method {0} Argument #{1} :{2}= {3}", injection.Method.Name, key, propertyName, dictionary[key] ?? "<null>"));
                }
            }
        }