gpt4 book ai didi

node.js - Azure函数上下文日志未正确记录,不同步

转载 作者:行者123 更新时间:2023-12-03 03:25:39 24 4
gpt4 key购买 nike

我希望以下内容按从上到下的顺序登录,但结果显示它们不按顺序排列

// Azure function handler
export const browseIssues = context => {
context.log.info({ a: 'first object', b: { q: 'test 1' } });
context.log.info({ a: 'second object', b: { q: 'test 2' } });
context.log.info({ a: 'third object', b: { q: 'test 3' } });

context.log.info(JSON.stringify({ a: 'first string', b: { q: 'test 1' } }));
context.log.info(JSON.stringify({ a: 'second string', b: { q: 'test 2' } }));
context.log.info(JSON.stringify({ a: 'third string', b: { q: 'test 3' } }));

context.log.info('first simple string');
context.log.info('second simple string');
context.log.info('third simple string');
}

结果: enter image description here

关于为什么会发生这种情况以及如何解决这个问题有什么想法吗?问题似乎仅限于 azure 上下文的日志中,因为 console.log 同步记录。

Node 版本:v18.12.1

此示例中未使用中间件。

编辑:额外信息 - 这是一个可重现的准系统仓库 https://github.com/keidyz/azure-function-logging-issue

最佳答案

从我的实践中,我发现了同样的问题,即上下文日志记录没有按顺序执行。

enter image description here

module.exports = async  function (context) {
context.log('JavaScript HTTP trigger function processed a request.');


context.log.info({ a: 'first object', b: { q: 'test 1' } });
context.log.info({ a: 'second object', b: { q: 'test 2' } });
context.log.info({ a: 'third object', b: { q: 'test 3' } });
context.log.info(JSON.stringify({ a: 'first string', b: { q: 'test 1' } }));
context.log.info(JSON.stringify({ a: 'second string', b: { q: 'test 2' } }));
context.log.info(JSON.stringify({ a: 'third string', b: { q: 'test 3' } }));

context.log.info('first simple string');
context.log.info('second simple string');
context.log.info('third simple string');
const responseMessage = "Hello Krishna, This Http Triggered Function executed successfully."


context.res = {
body: responseMessage
};
}

我已在 Azure Functions Host Issues 官方论坛中提出了 Azure Functions Node JS 的所有代码片段的问题,以获得上述结果 - # 9146并将进行相应跟进。

关于node.js - Azure函数上下文日志未正确记录,不同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75716633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com