-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: #195 verbose and porcelain are a cli feature and not in core
- Loading branch information
Showing
37 changed files
with
305 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
modules/cli/src/main/kotlin/datamaintain/cli/app/update/db/DatamaintainCliUpdateDbCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
modules/cli/src/main/kotlin/datamaintain/cli/app/utils/CliLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package datamaintain.cli.app.utils | ||
|
||
import ch.qos.logback.classic.Level | ||
import ch.qos.logback.classic.LoggerContext | ||
import org.slf4j.LoggerFactory | ||
|
||
/** | ||
* Translate cli level to logback level and set that level on datamaintain loggers | ||
*/ | ||
fun applyLoggerLevel(level: CliDatamaintainLoggerLevel) { | ||
val context = LoggerFactory.getILoggerFactory() as LoggerContext | ||
val datamaintainLogger = context.getLogger("datamaintain") | ||
|
||
when(level) { | ||
CliDatamaintainLoggerLevel.INFO -> datamaintainLogger.level = Level.INFO | ||
CliDatamaintainLoggerLevel.VERBOSE -> datamaintainLogger.level = Level.DEBUG | ||
CliDatamaintainLoggerLevel.PORCELAIN -> datamaintainLogger.level = Level.ERROR | ||
else -> error("Cannot set log level of $level") | ||
} | ||
} | ||
|
||
enum class CliDatamaintainLoggerLevel { | ||
// normal log level | ||
INFO, | ||
|
||
// debug log level | ||
VERBOSE, | ||
|
||
// special mode for cli, the datamaintain logs are disabled (except error) and specific logs are print. | ||
// This is use for scripts that may need to parse datamaintain logs (e.g: for take in account execution results) | ||
PORCELAIN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/datamaintain/core/util/PorcelainUtil.kt → ...tamaintain/cli/app/utils/PorcelainUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package datamaintain.core.util | ||
package datamaintain.cli.app.utils | ||
|
||
import java.nio.file.Path | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.