arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.12958cs.SE
收藏

Go Static:上下文化日志语句生成

Go Static: Contextualized Logging Statement Generation

Yichen Li, Yintong Huo, Renyi Zhong, Zhihan Jiang, Jinyang Liu, Junjie Huang, Jiazhen Gu, Pinjia He, Michael R. Lyu

AI总结:

针对单方法输入缺乏外部上下文导致自动日志生成性能不佳的问题,提出首个利用方法间静态上下文的日志语句生成方法SCLogger,通过构建上下文化提示和细化变量类型信息,显著提升了多项准确率并在多种大模型上展现出泛化能力。

摘要:

日志实践已被广泛研究,以协助开发人员编写合适的日志语句来记录软件行为。尽管已经提出了许多自动日志记录方法,但由于单方法输入的限制,缺乏方法外部的有用编程上下文,其性能仍然不能令人满意。具体而言,我们指出了单方法上下文的三个固有局限性:日志语句的静态范围有限、日志风格不一致以及缺失日志变量的类型信息。为了解决这些局限性,我们提出了SCLogger,这是第一种具有方法间静态上下文的上下文化日志语句生成方法。首先,SCLogger通过静态分析提取方法间上下文,为语言模型构建上下文化提示,以生成初步日志语句。上下文化提示由扩展的静态范围和采样的相似方法组成,并按思维链(COT)策略进行排序。其次,SCLogger通过为语言模型制定新的细化提示来改进日志变量的访问,该提示包含了初步日志语句中变量的详细类型信息。评估结果表明,SCLogger在日志位置准确率上超越了最先进的方法8.7%,在级别准确率上超越32.1%,在变量精度上超越19.6%,在文本BLEU-4得分上超越138.4%。此外,SCLogger在一系列大语言模型上持续提升了日志语句生成的性能,从而展示了该方法的泛化能力。

英文摘要:

Logging practices have been extensively investigated to assist developers in writing appropriate logging statements for documenting software behaviors. Although numerous automatic logging approaches have been proposed, their performance remains unsatisfactory due to the constraint of the single-method input, without informative programming context outside the method. Specifically, we identify three inherent limitations with single-method context: limited static scope of logging statements, inconsistent logging styles, and missing type information of logging variables. To tackle these limitations, we propose SCLogger, the first contextualized logging statement generation approach with inter-method static contexts. First, SCLogger extracts inter-method contexts with static analysis to construct the contextualized prompt for language models to generate a tentative logging statement. The contextualized prompt consists of an extended static scope and sampled similar methods, ordered by the chain-of-thought (COT) strategy. Second, SCLogger refines the access of logging variables by formulating a new refinement prompt for language models, which incorporates detailed type information of variables in the tentative logging statement. The evaluation results show that SCLogger surpasses the state-of-the-art approach by 8.7% in logging position accuracy, 32.1% in level accuracy, 19.6% in variable precision, and 138.4% in text BLEU-4 score. Furthermore, SCLogger consistently boosts the performance of logging statement generation across a range of large language models, thereby showcasing the generalizability of this approach.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑