-
Notifications
You must be signed in to change notification settings - Fork 92
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 #481 from balancer/add-logger
Add logger to suppress production logs
- Loading branch information
Showing
23 changed files
with
104 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export class Logger { | ||
private enableLogging: boolean; | ||
|
||
private static instance: Logger; | ||
|
||
private constructor() { | ||
this.enableLogging = true; // Logging is initially enabled | ||
} | ||
|
||
static getInstance(): Logger { | ||
if (!Logger.instance) { | ||
Logger.instance = new Logger(); | ||
} | ||
return Logger.instance; | ||
} | ||
|
||
setLoggingEnabled(enabled: boolean): void { | ||
this.enableLogging = enabled; | ||
} | ||
|
||
info(message: string): void { | ||
if (this.enableLogging) { | ||
console.log(`[INFO] ${message}`); | ||
} | ||
} | ||
|
||
warn(message: string): void { | ||
if (this.enableLogging) { | ||
console.warn(`[WARN] ${message}`); | ||
} | ||
} | ||
|
||
error(message: string): void { | ||
if (this.enableLogging) { | ||
console.error(`[ERROR] ${message}`); | ||
} | ||
} | ||
} |
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
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
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
34 changes: 4 additions & 30 deletions
34
balancer-js/src/modules/pools/pool-types/concerns/fx/exit.concern.ts
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,41 +1,15 @@ | ||
import { | ||
ExitConcern, | ||
ExitExactBPTInAttributes, | ||
ExitExactBPTInParameters, | ||
ExitExactTokensOutAttributes, | ||
ExitExactTokensOutParameters, | ||
} from '@/modules/pools/pool-types/concerns/types'; | ||
|
||
export class FXExitConcern implements ExitConcern { | ||
buildExitExactTokensOut({ | ||
exiter, | ||
pool, | ||
tokensOut, | ||
amountsOut, | ||
slippage, | ||
wrappedNativeAsset, | ||
}: ExitExactTokensOutParameters): ExitExactTokensOutAttributes { | ||
console.log( | ||
exiter, | ||
pool, | ||
tokensOut, | ||
amountsOut, | ||
slippage, | ||
wrappedNativeAsset | ||
); | ||
throw new Error('Not implemented'); | ||
buildExitExactTokensOut(): ExitExactTokensOutAttributes { | ||
throw new Error('FXExitConcern Not implemented'); | ||
} | ||
|
||
buildRecoveryExit({ | ||
exiter, | ||
pool, | ||
bptIn, | ||
slippage, | ||
}: Pick< | ||
ExitExactBPTInParameters, | ||
'exiter' | 'pool' | 'bptIn' | 'slippage' | ||
>): ExitExactBPTInAttributes { | ||
console.log(exiter, pool, bptIn, slippage); | ||
throw new Error('Not implemented'); | ||
buildRecoveryExit(): ExitExactBPTInAttributes { | ||
throw new Error('FXExitConcern Not implemented'); | ||
} | ||
} |
20 changes: 2 additions & 18 deletions
20
balancer-js/src/modules/pools/pool-types/concerns/fx/join.concern.ts
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,26 +1,10 @@ | ||
import { | ||
JoinConcern, | ||
JoinPoolAttributes, | ||
JoinPoolParameters, | ||
} from '@/modules/pools/pool-types/concerns/types'; | ||
|
||
export class FXJoinConcern implements JoinConcern { | ||
buildJoin({ | ||
joiner, | ||
pool, | ||
tokensIn, | ||
amountsIn, | ||
slippage, | ||
wrappedNativeAsset, | ||
}: JoinPoolParameters): JoinPoolAttributes { | ||
console.log( | ||
joiner, | ||
pool, | ||
tokensIn, | ||
amountsIn, | ||
slippage, | ||
wrappedNativeAsset | ||
); | ||
throw new Error('Not implemented'); | ||
buildJoin(): JoinPoolAttributes { | ||
throw new Error('FXJoinConcern Not implemented'); | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
balancer-js/src/modules/pools/pool-types/concerns/fx/spotPrice.concern.ts
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,9 +1,7 @@ | ||
import { SpotPriceConcern } from '@/modules/pools/pool-types/concerns/types'; | ||
import { Pool } from '@/types'; | ||
|
||
export class FXSpotPriceConcern implements SpotPriceConcern { | ||
calcPoolSpotPrice(tokenIn: string, tokenOut: string, pool: Pool): string { | ||
console.log(tokenIn, tokenOut, pool); | ||
throw new Error('Not implemented'); | ||
calcPoolSpotPrice(): string { | ||
throw new Error('FXSpotPriceConcern Not implemented'); | ||
} | ||
} |
20 changes: 2 additions & 18 deletions
20
balancer-js/src/modules/pools/pool-types/concerns/gyro/join.concern.ts
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,26 +1,10 @@ | ||
import { | ||
JoinConcern, | ||
JoinPoolAttributes, | ||
JoinPoolParameters, | ||
} from '@/modules/pools/pool-types/concerns/types'; | ||
|
||
export class GyroJoinConcern implements JoinConcern { | ||
buildJoin({ | ||
joiner, | ||
pool, | ||
tokensIn, | ||
amountsIn, | ||
slippage, | ||
wrappedNativeAsset, | ||
}: JoinPoolParameters): JoinPoolAttributes { | ||
console.log( | ||
joiner, | ||
pool, | ||
tokensIn, | ||
amountsIn, | ||
slippage, | ||
wrappedNativeAsset | ||
); | ||
throw new Error('Not implemented'); | ||
buildJoin(): JoinPoolAttributes { | ||
throw new Error('GyroJoinConcern Not implemented'); | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
balancer-js/src/modules/pools/pool-types/concerns/gyro/spotPrice.concern.ts
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,9 +1,7 @@ | ||
import { SpotPriceConcern } from '@/modules/pools/pool-types/concerns/types'; | ||
import { Pool } from '@/types'; | ||
|
||
export class GyroSpotPriceConcern implements SpotPriceConcern { | ||
calcPoolSpotPrice(tokenIn: string, tokenOut: string, pool: Pool): string { | ||
console.log(tokenIn, tokenOut, pool); | ||
throw new Error('Not implemented'); | ||
calcPoolSpotPrice(): string { | ||
throw new Error('GyroSpotPriceConcern Not implemented'); | ||
} | ||
} |
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.