Skip to content

Commit 0883e4a

Browse files
tomnistomas mccandless
andauthored
Clear staging directory before deploying artifacts (#118)
* minor logging tweaks, make LoggerInit an object * make sure to clean staging directory * use -q flag --------- Co-authored-by: tomas mccandless <[email protected]>
1 parent c5bd068 commit 0883e4a

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

publish.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ if [[ $RELEASE_TYPE = 'final' || $RELEASE_TYPE = 'candidate' ]]
6767
then
6868
if git remote show origin | grep "Fetch URL: [email protected]:Workday/warp-core.git"; then
6969
echo "we are on main fork, proceeding with $RELEASE_TYPE release"
70+
./gradlew -q clean -PallScalaVersions
7071
# create our repo tag
7172
# TODO despite being in `runOnceTasks`, it appears `candidate` is run multiple times with -PallScalaVersions, incorrectly creating multiple tags
7273
echo "creating repo tag for $RELEASE_TYPE release"

warp-core/src/main/scala/com/workday/warp/config/WarpPropertyManager.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.workday.warp.logger.{LoggerInit, WarpLogUtils}
77
import org.apache.commons.configuration2.PropertiesConfiguration
88
import org.apache.commons.configuration2.builder.fluent.Configurations
99
import org.apache.commons.configuration2.ex.ConfigurationException
10+
import org.slf4j.{Logger, LoggerFactory}
1011

1112
import scala.collection.JavaConverters._
1213
import scala.collection.mutable
@@ -22,7 +23,12 @@ import scala.util.{Failure, Success, Try}
2223
* Created by tomas.mccandless on 10/21/15.
2324
* Based on a class created by michael.ottati on 3/29/13
2425
*/
25-
object WarpPropertyManager extends LoggerInit {
26+
object WarpPropertyManager {
27+
28+
LoggerInit.init()
29+
30+
@transient
31+
protected lazy val logger: Logger = LoggerFactory.getLogger(getClass.getName)
2632

2733
/**
2834
* Properties containing this prefix will be passed through as system properties with this

warp-core/src/main/scala/com/workday/warp/logger/LoggerInit.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ import scala.util.{Failure, Try}
1010
* This trait is intended to quiesce debug entries from transitive dependencies that occur in the early stages of initialization
1111
* before we have had a chance to configure the logger properly.
1212
*/
13-
trait LoggerInit {
13+
object LoggerInit {
1414

15-
// early configuration of this log level to
16-
// Prevent spurious log entries from commons-beanutils library, which is a transitive dependency.
17-
getLoggerContext.foreach(_.getLogger("org.apache.commons.beanutils.converters").setLevel(Level.INFO))
15+
/** Early logger configuration to prevent spurious log entries. */
16+
def init(): Unit = {
17+
LoggerInit.getLoggerContext.foreach(_.getLogger("org.apache.commons.beanutils.converters").setLevel(Level.INFO))
18+
}
1819

1920
/**
2021
* Retrieve the LoggerContext as a Try from the ILoggerFactory.
2122
*
2223
* Because we want to programmatically configure the logger, we need some methods only available via logback rather
2324
* than slf4j. This necessitates a cast, however if slf4j is bound at runtime to some concrete implementation other
2425
* than logback (e.g., slf4j-simple), this fails. Configuration will fallback to the default for that implementation.
25-
*
26-
* @return Try[LoggerContext]
2726
*/
28-
def getLoggerContext: Try[LoggerContext] = {
27+
lazy val getLoggerContext: Try[LoggerContext] = {
2928
Try(LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]).recoverWith { case e =>
3029
logger.warn("Could not cast to logback LoggerContext at runtime, logger will run with default configuration")
3130
Failure(e)
@@ -34,4 +33,4 @@ trait LoggerInit {
3433

3534
@transient
3635
protected lazy val logger: Logger = LoggerFactory.getLogger(getClass.getName)
37-
}
36+
}

warp-core/src/main/scala/com/workday/warp/logger/WarpLogUtils.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object WarpLogUtils extends WarpLogging {
3636
CustomLoggerLevels("com.workday.warp", this.parseLevel(WARP_CONSOLE_LOG_LEVEL.value, WARP_CONSOLE_LOG_LEVEL.defaultValue))
3737
)
3838

39-
getLoggerContext.foreach { context =>
39+
LoggerInit.getLoggerContext.foreach { context =>
4040
val logEncoder: PatternLayoutEncoder = new PatternLayoutEncoder
4141
logEncoder.setContext(context)
4242
logEncoder.setPattern(LOG_FORMAT)
@@ -86,7 +86,7 @@ object WarpLogUtils extends WarpLogging {
8686
* @param writerConfig - configuration properties for each new fileWriter
8787
*/
8888
def addFileWriter(writerConfig: WriterConfig): Unit = {
89-
getLoggerContext.map { context =>
89+
LoggerInit.getLoggerContext.map { context =>
9090
// Create a logEncoder for the logFileAppender
9191
val logEncoder2: PatternLayoutEncoder = new PatternLayoutEncoder
9292
logEncoder2.setContext(context)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
package com.workday.warp.logger
22

33
import com.workday.warp.config.WarpPropertyManager
4+
import org.slf4j.{Logger, LoggerFactory}
45

56
/**
67
* Trait that initializes the logger configuration for Warp.
78
* It sets up the logger context and initializes properties for use in logger configuration.
89
*
910
* This trait is intended to be mixed into classes that require logging capabilities.
1011
*/
11-
trait WarpLogging extends LoggerInit {
12+
trait WarpLogging {
13+
14+
LoggerInit.init()
1215

1316
// Initializes properties for use in logger configuration
1417
WarpPropertyManager.version
18+
19+
@transient
20+
protected lazy val logger: Logger = LoggerFactory.getLogger(getClass.getName)
1521
}
1622

1723
class WarpLoggingWrapper extends WarpLogging

0 commit comments

Comments
 (0)