コード例 #1
0
        public void QueueMessage(LogMsg msg)
        {
            if (msg == null)
            {
                return;
            }

            int isError = 0;

            if (msg.id == null) //should be null unless someone is using our API directly and setting it
            {
                msg.id = SequentialGuid.NewGuid().ToString();
            }

            if (msg.Ex != null)
            {
                isError = 1;
            }

            // works on the assumption that the epochMS will always be incrementing as it reaches this point
            if (_lastEpochMs < msg.EpochMs)
            {
                // reset counter if we are no longer in the same ms
                //https://msdn.microsoft.com/en-us/library/system.threading.interlocked_methods(v=vs.110).aspx
                Interlocked.Exchange(ref _lastEpochMs, msg.EpochMs);
                Interlocked.Exchange(ref _millisecondCount, 1);
                msg.Order = 1;
            }
            else if (_lastEpochMs == msg.EpochMs)
            {
                msg.Order = Interlocked.Increment(ref _millisecondCount);
            }
            // else defaulted to 0

            //Used by Stackify profiler only
            if (Logger.PrefixEnabled())
            {
                msg.SetLogMsgID(msg.id, isError, msg.Level, msg.Msg, msg.data);
            }
            else
            {
                msg.SetLogMsgID(msg.id, isError, msg.Level, null, null);
            }


            //We need to do everything up to this point for sasquatch. Even if we aren't uploading the log.
            if (this.CanQueue())
            {
                _LogQueue.QueueLogMessage(msg);
            }
        }
コード例 #2
0
        public void QueueMessage(LogMsg msg)
        {
            if (msg == null)
            {
                return;
            }

            int isError = 0;

            if (msg.id == null) //should be null unless someone is using our API directly and setting it
            {
                msg.id = SequentialGuid.NewGuid().ToString();
            }

            if (msg.Ex != null)
            {
                isError = 1;
            }

            //Used by Stackify profiler only
            if (Logger.PrefixEnabled())
            {
                msg.SetLogMsgID(msg.id, isError, msg.Level, msg.Msg, msg.data);
            }
            else
            {
                msg.SetLogMsgID(msg.id, isError, msg.Level, null, null);
            }


            //We need to do everything up to this point for sasquatch. Even if we aren't uploading the log.
            if (this.CanQueue())
            {
                _LogQueue.QueueLogMessage(msg);
            }
        }