mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
added logger
This commit is contained in:
parent
f5bb016a18
commit
97fc3d6c1c
18
src/logger.js
Normal file
18
src/logger.js
Normal file
@ -0,0 +1,18 @@
|
||||
export default class Logger {
|
||||
static dispatch(verb, ...args) {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console[verb](...args)
|
||||
}
|
||||
|
||||
static log(...args) {
|
||||
Logger.dispatch('log', ...args)
|
||||
}
|
||||
|
||||
static debug(...args) {
|
||||
Logger.dispatch('debug', ...args)
|
||||
}
|
||||
|
||||
static error(...args) {
|
||||
Logger.dispatch('error', ...args)
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* global fetch */
|
||||
/* eslint-disable no-console */
|
||||
import Logger from 'logger'
|
||||
|
||||
export default class OceanAgent {
|
||||
constructor(connectionUrl) {
|
||||
@ -20,17 +20,17 @@ export default class OceanAgent {
|
||||
headers: { 'Content-type': 'application/json' }
|
||||
})
|
||||
.then(response => {
|
||||
console.log('Success:', response)
|
||||
Logger.log('Success:', response)
|
||||
if (response.ok) {
|
||||
console.log('Success:', response)
|
||||
Logger.log('Success:', response)
|
||||
return true
|
||||
}
|
||||
console.log('Failed: ', response.status, response.statusText)
|
||||
Logger.log('Failed: ', response.status, response.statusText)
|
||||
return false
|
||||
// throw new Error(response.statusText ? response.statusText : `publish asset failed with status ${response.status}`)
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(`Publish asset to ocean database could not be completed: ${error.message()}`)
|
||||
Logger.log(`Publish asset to ocean database could not be completed: ${error.message()}`)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import Web3 from 'web3'
|
||||
import ContractLoader from './contractLoader'
|
||||
import Logger from './logger'
|
||||
|
||||
const DEFAULT_GAS = 300000
|
||||
|
||||
@ -94,7 +93,7 @@ export default class OceanKeeper {
|
||||
paid: await this.verifyOrderPayment(event.args._id).then((received) => received),
|
||||
key: null
|
||||
}))
|
||||
console.debug('got orders: ', orders)
|
||||
Logger.debug('got orders: ', orders)
|
||||
return orders
|
||||
}
|
||||
|
||||
@ -110,7 +109,7 @@ export default class OceanKeeper {
|
||||
price,
|
||||
{ from: publisherAddress, gas: this.defaultGas }
|
||||
)
|
||||
console.log('registered: ', result)
|
||||
Logger.log('registered: ', result)
|
||||
return assetId
|
||||
}
|
||||
|
||||
@ -172,7 +171,7 @@ export default class OceanKeeper {
|
||||
event.watch((error, result) => { // eslint-disable-line security/detect-non-literal-fs-filename
|
||||
event.stopWatching()
|
||||
if (error) {
|
||||
console.log(`Error in keeper ${eventName} event: `, error)
|
||||
Logger.log(`Error in keeper ${eventName} event: `, error)
|
||||
}
|
||||
callback(result, error)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user