一句话:首次系统研究日志与代码的逻辑/语义时序关系,提出检测规则与工具 TempoLo,并在项目中确认修复时序不一致。
日志文本若产生误导,会妨碍开发者使用日志;而日志常记录系统行为的时序信息。现有日志建议研究较少考察日志与代码的时序关系。本文首次系统研究两类时序关系:可由日志语句与代码执行顺序推断的逻辑时序关系,以及由日志文本语义推断的语义时序关系。作者通过定性分析刻画二者及其不一致,制定检测规则并实现工具 TempoLo。在四个项目上的评估表明,TempoLo 能有效检测时序不一致且误报较少;向开发者报告 15 个实例后,来自三个项目的 13 个被确认并修复,另 2 个待处理。该工作为理解日志与代码关系奠定基础。
Prior work shows that misleading logging texts (i.e., the textual descriptions in logging statements) can be counterproductive for developers during their use of logs. One of the most important types of information provided by logs is the temporal information of the recorded system behavior. For example, a logging text may use a perfective aspect to describe a fact that an important system event has finished. Although prior work has performed extensive studies on automated logging suggestions, few of these studies investigate the temporal relations between logging and code. In this work, we make the first attempt to comprehensively study the temporal relations between logging and its corresponding source code. In particular, we focus on two types of temporal relations: (1) logical temporal relations, which can be inferred from the execution order between the logging statement and the corresponding source code; and (2) semantic temporal relations, which can be inferred based on the semantic meaning of the logging text. We first perform qualitative analyses to study these two types of logging-code temporal relations and the inconsistency between them. As a result, we derive rules to detect these two types of temporal relations and their inconsistencies. Based on these rules, we propose a tool named TempoLo to automatically detect the issues of temporal inconsistencies between logging and code. Through an evaluation of four projects, we find that TempoLo can effectively detect temporal inconsistencies with a small number of false positives. To gather developers' feedback on whether such inconsistencies are worth fixing, we report 15 detected instances from these projects to developers. 13 instances from three projects are confirmed and fixed, while two instances of the remaining project are pending at the time of this writing. Our work lays the foundation for describing temporal relations between logging and code and demonstrates the potential for a deeper understanding of the relationship between logging and code.