Scala compiler plugin for detecting log statements in source code
Note: This project is work in progress and currently not stable.
DeLoS is a Scala Compiler Plugin that extracts log statements from provided source code.
The tool is intended for research purposes in the area of analysing and improving log statements.
build.sbt
does not need to be changed manuallyTo use the plugin, the following needs to be added to build.sbt
:
addCompilerPlugin("net.scholtzan" %% "delos" % "0.0.1")
Currently only log statements of SLF4J are detected.
To add support for more libraries a new Inspector
class can be added to the log
package.
This class needs to extend LogStatementInspector
and override the inspect
method which traverses the abstract syntax tree (AST) of the source code files.
Using Scalas pattern matching the AST is traversed and log statements are detected (see Scala Reflection).SLF4JInspector
provides an exemplary implementation of a log statement inspector.
To test the compiler plugin, for each inspector a InspectorSpec
can be added to test
.
These specs extend the trait LogInspectorSpec
which takes care of running the compiler plugin against provided code and checks if the results are as expected.SLF4JInspectorSpec
provides some examples for such tests.