Go Static: Contextualized Logging Statement Generation

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Li, Yichen, Huo, Yintong, Zhong, Renyi, Jiang, Zhihan, Liu, Jinyang, Huang, Junjie, Gu, Jiazhen, He, Pinjia, Lyu, Michael R.
Natura: Preprint
Pubblicazione: 2024
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917594282328064
author Li, Yichen
Huo, Yintong
Zhong, Renyi
Jiang, Zhihan
Liu, Jinyang
Huang, Junjie
Gu, Jiazhen
He, Pinjia
Lyu, Michael R.
author_facet Li, Yichen
Huo, Yintong
Zhong, Renyi
Jiang, Zhihan
Liu, Jinyang
Huang, Junjie
Gu, Jiazhen
He, Pinjia
Lyu, Michael R.
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2402_12958
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Go Static: Contextualized Logging Statement Generation
Li, Yichen
Huo, Yintong
Zhong, Renyi
Jiang, Zhihan
Liu, Jinyang
Huang, Junjie
Gu, Jiazhen
He, Pinjia
Lyu, Michael R.
Software Engineering
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.
title Go Static: Contextualized Logging Statement Generation
topic Software Engineering
url https://arxiv.org/abs/2402.12958