@@ -5,6 +5,7 @@ import { RunQuery } from '../lib/connectionPool'
55import { DEFAULT_SYSTEM_SCHEMAS } from '../lib/constants'
66import { Tables } from '../lib/interfaces'
77import sqlTemplates = require( '../lib/sql' )
8+ import { logger } from '../lib/logger'
89
910/**
1011 * @param {string } [include_system_schemas=false] - Return system schemas as well as user schemas
@@ -25,7 +26,7 @@ router.get('/', async (req, res) => {
2526 if ( ! include_system_schemas ) payload = removeSystemSchemas ( data )
2627 return res . status ( 200 ) . json ( payload )
2728 } catch ( error ) {
28- console . log ( 'throwing error' , error )
29+ logger . error ( { error, req : req . body } )
2930 res . status ( 500 ) . json ( { error : error . message } )
3031 }
3132} )
@@ -46,8 +47,7 @@ router.post('/', async (req, res) => {
4647 const newPolicy = await getPolicyByName ( pcConnection , name , schema , table )
4748 return res . status ( 200 ) . json ( newPolicy )
4849 } catch ( error ) {
49- // For this one, we always want to give back the error to the customer
50- console . log ( 'POST error!' , error )
50+ logger . error ( { error, req : req . body } )
5151 res . status ( 400 ) . json ( { error : error . message } )
5252 }
5353} )
@@ -83,8 +83,7 @@ router.patch('/:id', async (req, res) => {
8383 const updated = await getPolicyById ( pcConnection , id )
8484 return res . status ( 200 ) . json ( updated )
8585 } catch ( error ) {
86- // For this one, we always want to give back the error to the customer
87- console . log ( 'Soft error!' , error )
86+ logger . error ( { error, req : req . body } )
8887 res . status ( 400 ) . json ( { error : error . message } )
8988 }
9089} )
@@ -105,7 +104,7 @@ router.delete('/:id', async (req, res) => {
105104
106105 return res . status ( 200 ) . json ( policy )
107106 } catch ( error ) {
108- console . log ( 'throwing error' , error )
107+ logger . error ( { error, req : req . body } )
109108 res . status ( 400 ) . json ( { error : error . message } )
110109 }
111110} )
0 commit comments