File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ export class QueryLogPlugin extends StarbasePlugin {
2020 executionContext ?: ExecutionContext
2121 // Add TTL configuration (default 1 day)
2222 private readonly ttl : number = 1
23+ // Enables the omission of queries who contain the prefix
24+ omitEnabled ?: boolean = false
25+ // Prefix that if a query contains it won't be logged
26+ omitPrefix : string = '--OMIT'
2327
2428 state = {
2529 startTime : new Date ( ) ,
@@ -28,9 +32,18 @@ export class QueryLogPlugin extends StarbasePlugin {
2832 query : '' ,
2933 }
3034
31- constructor ( opts ?: { ctx ?: ExecutionContext } ) {
35+ constructor ( opts ?: {
36+ ctx ?: ExecutionContext
37+ enableOmit ?: boolean
38+ omitPrefix ?: string
39+ } ) {
3240 super ( 'starbasedb:query-log' )
3341 this . executionContext = opts ?. ctx
42+ this . omitEnabled = opts ?. enableOmit
43+
44+ if ( opts ?. omitPrefix ) {
45+ this . omitPrefix = opts ?. omitPrefix
46+ }
3447 }
3548
3649 override async register ( app : StarbaseApp ) {
@@ -74,7 +87,12 @@ export class QueryLogPlugin extends StarbasePlugin {
7487 this . state . totalTime =
7588 this . state . endTime . getTime ( ) - this . state . startTime . getTime ( )
7689
77- if ( opts . dataSource ) {
90+ // Queries can be omitted from
91+ if (
92+ opts . dataSource &&
93+ ! opts . sql . toUpperCase ( ) . trim ( ) . startsWith ( this . omitPrefix ) &&
94+ this . omitEnabled
95+ ) {
7896 this . addQuery ( opts ?. dataSource )
7997 }
8098
You can’t perform that action at this time.
0 commit comments