public void Log_Verbose_LogData_EmitsExpectedEvent()
        {
            string eventName            = string.Empty;
            string details              = string.Empty;
            string message              = "TestMessage";
            string functionInvocationId = Guid.NewGuid().ToString();
            string activityId           = Guid.NewGuid().ToString();
            var    scopeState           = new Dictionary <string, object>
            {
                [ScriptConstants.LogPropertyFunctionInvocationIdKey] = functionInvocationId
            };

            _mockEventGenerator.Setup(p => p.LogFunctionTraceEvent(LogLevel.Debug, _subscriptionId, _websiteName, _functionName, eventName, _category, details, message, string.Empty, string.Empty, functionInvocationId, _hostInstanceId, activityId));

            var logData = new Dictionary <string, object>
            {
                [ScriptConstants.LogPropertyActivityIdKey] = activityId
            };

            using (_logger.BeginScope(scopeState))
            {
                _logger.Log(LogLevel.Debug, 0, logData, null, (state, ex) => message);
            }

            _mockEventGenerator.VerifyAll();
        }
예제 #2
0
        public void Log_UsesScopeFunctionName_IfNoCategory(string key)
        {
            var logScope = new Dictionary <string, object>
            {
                [key] = "TestFunction3"
            };

            var logger = new SystemLogger(_hostInstanceId, "Not.A.Function", _mockEventGenerator.Object, _environment, _debugStateProvider.Object, null, new LoggerExternalScopeProvider());

            _mockEventGenerator.Setup(p => p.LogFunctionTraceEvent(LogLevel.Debug, It.IsAny <string>(), It.IsAny <string>(), "TestFunction3", It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));

            using (logger.BeginScope(logScope))
            {
                logger.LogDebug("TestMessage");
            }
        }