Skip to content

Commit

Permalink
chore: added logs to debug the query method (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
javierdelafuentesales authored Feb 16, 2024
1 parent b9aca7e commit 2d67b5d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@streamyard/typeorm",
"private": true,
"version": "0.3.16-3",
"version": "0.3.16-4-beta",
"description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB, Spanner databases.",
"license": "MIT",
"readmeFilename": "README.md",
Expand Down
31 changes: 31 additions & 0 deletions src/driver/spanner/SpannerQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
if (this.isReleased) throw new QueryRunnerAlreadyReleasedError()

try {
this.driver.connection.logger.log(
"info",
"typeorm:query - start",
this,
)
const queryStartTime = +new Date()
await this.connect()
let rawResult:
Expand All @@ -182,6 +187,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {

try {
this.driver.connection.logger.logQuery(query, parameters, this)
this.driver.connection.logger.log(
"info",
"typeorm:query - before run",
this,
)
rawResult = await executor.run({
sql: query,
params: parameters
Expand All @@ -192,7 +202,18 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
: undefined,
json: true,
})

this.driver.connection.logger.log(
"info",
"typeorm:query - after run",
this,
)
if (!this.isTransactionActive && !isSelect) {
this.driver.connection.logger.log(
"info",
"typeorm:query -commit",
this,
)
await this.sessionTransaction.commit()
}
} catch (error) {
Expand Down Expand Up @@ -220,6 +241,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
this,
)

this.driver.connection.logger.log(
"info",
"typeorm:query - preparing result",
this,
)
const result = new QueryResult()

result.raw = rawResult
Expand All @@ -232,6 +258,11 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
return result.records
}

this.driver.connection.logger.log(
"info",
"typeorm:query - end",
this,
)
return result
} catch (err) {
this.driver.connection.logger.logQueryError(
Expand Down

0 comments on commit 2d67b5d

Please sign in to comment.