forked from ShiftLeftSecurity/codepropertygraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Privado-Inc/stats-logging
Merge `stats-logging` to `master`
- Loading branch information
1 parent
396b4d9
commit a1f632e
Showing
3 changed files
with
34 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
codepropertygraph/src/main/scala/io/shiftleft/utils/StatsCollector.scala
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,28 @@ | ||
package io.shiftleft.utils | ||
|
||
object StatsLogger extends DataLogger { | ||
private var logger: Option[DataLogger] = None | ||
def initialise(logger: Option[DataLogger] = None): Unit = { | ||
this.logger = logger | ||
} | ||
|
||
def initiateNewStage( | ||
stageName: String, | ||
stageFullName: Option[String] = None, | ||
additionalMetaDataToLog: String = STAGE_NOT_SET | ||
): Unit = { logger.foreach(log => log.initiateNewStage(stageName, stageFullName, additionalMetaDataToLog)) } | ||
|
||
def endLastStage(): Unit = { logger.foreach(log => log.endLastStage()) } | ||
} | ||
|
||
trait DataLogger { | ||
// Constant used when stage or subStage is not set. | ||
val STAGE_NOT_SET = "<not set>" | ||
def initiateNewStage( | ||
stageName: String, | ||
stageFullName: Option[String] = None, | ||
additionalMetaDataToLog: String = STAGE_NOT_SET | ||
): Unit | ||
|
||
def endLastStage(): Unit | ||
} |