Recipe Name:
SLF4J Logging: Replace java.util.logging with SLF4J (Info)
Description:
Standardise on SLF4J by replacing this call
Level:
marked_information
Language:
- java
Tags:
- SLF4J
- framework specific
- logging
- quality
Recipe
id: scw:logging:slf4j-jul-info version: 10 metadata: name: 'SLF4J Logging: Replace java.util.logging with SLF4J (Info)' shortDescription: Standardise on SLF4J by replacing this call level: marked_information language: java scwCategory: insufficient_logging:generic cweCategory: 778 enabled: true tags: SLF4J;framework specific;logging;quality search: methodcall: in: typeDeclaration: anyOf: - with: child: field: name: logger type: org.slf4j.Logger - without: child: field: name: logger type: reference: not: org.slf4j.Logger checkInheritance: true name: matches: info type: java.util.logging.Logger availableFixes: - name: '[OPTIONAL] Replace with SLF4J debug function' actions: - rewrite: to: logger.debug({{{arguments}}}) target: self - addField: field: private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger({{{ containingClass.containingClass.name }}}.class); target: parentClass - name: '[OPTIONAL] Replace with SLF4J error function' actions: - rewrite: to: logger.error({{{arguments}}}) target: self - addField: field: private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger({{{ containingClass.containingClass.name }}}.class); target: parentClass - name: ' [RECOMMENDED] Replace with SLF4J info function' actions: - rewrite: to: logger.info({{{arguments}}}) target: self - addField: field: private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger({{{ containingClass.containingClass.name }}}.class); target: parentClass - name: '[OPTIONAL] Replace with SLF4J warn function' actions: - rewrite: to: logger.warn({{{arguments}}}) target: self - addField: field: private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger({{{ containingClass.containingClass.name }}}.class); target: parentClass - name: '[OPTIONAL] Replace with SLF4J trace function' actions: - rewrite: to: logger.trace({{{arguments}}}) target: self - addField: field: private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger({{{ containingClass.containingClass.name }}}.class); target: parentClass