Skip to content

Commit

Permalink
chore(client): Log SQLite version when starting in debug mode (#648)
Browse files Browse the repository at this point in the history
Log the SQLite version that is running on the client when in debug mode.
  • Loading branch information
davidmartos96 committed Nov 14, 2023
1 parent 2514a51 commit e92a7e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clients/typescript/src/satellite/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface SatelliteOpts {
clearOnBehindWindow: boolean
/** Backoff options for connecting with Electric*/
connectionBackOffOptions: ConnectionBackoffOptions
/** With debug mode enabled, Satellite can show additional logs. */
debug: boolean
}

export interface SatelliteOverrides {
Expand Down Expand Up @@ -49,6 +51,7 @@ export const satelliteDefaults: SatelliteOpts = {
numOfAttempts: 50,
timeMultiple: 2,
},
debug: false,
}

export const satelliteClientDefaults = {
Expand Down
11 changes: 11 additions & 0 deletions clients/typescript/src/satellite/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ export class SatelliteProcess implements Satellite {
}

async start(authConfig: AuthConfig): Promise<ConnectionWrapper> {
if (this.opts.debug) {
await this.logSQLiteVersion()
}

await this.migrator.up()

const isVerified = await this._verifyTableStructure()
Expand Down Expand Up @@ -281,6 +285,13 @@ export class SatelliteProcess implements Satellite {
return { connectionPromise }
}

private async logSQLiteVersion(): Promise<void> {
const sqliteVersionRow = await this.adapter.query({
sql: 'SELECT sqlite_version() AS version',
})
Log.info(`Using SQLite version: ${sqliteVersionRow[0]['version']}`)
}

async _setAuthState(authState: AuthState): Promise<void> {
this._authState = authState
}
Expand Down
1 change: 1 addition & 0 deletions clients/typescript/src/satellite/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class GlobalRegistry extends BaseRegistry {
const satelliteOpts: SatelliteOpts = {
...satelliteDefaults,
connectionBackOffOptions: config.connectionBackOffOptions,
debug: config.debug,
}

const satellite = new SatelliteProcess(
Expand Down

0 comments on commit e92a7e3

Please sign in to comment.