@@ -15,6 +15,8 @@ const MulticastDNS = require('libp2p-mdns')
1515const WS = require ( 'libp2p-websockets' )
1616const Bootstrap = require ( 'libp2p-bootstrap' )
1717const errorHandler = require ( './error-handler' )
18+ const LOG = 'ipfs:http-api'
19+ const LOG_ERROR = 'ipfs:http-api:error'
1820
1921function hapiInfoToMultiaddr ( info ) {
2022 let hostname = info . host
@@ -48,8 +50,8 @@ function serverCreator (serverAddrs, createServer, ipfs) {
4850class HttpApi {
4951 constructor ( options ) {
5052 this . _options = options || { }
51- this . _log = debug ( 'ipfs:http-api' )
52- this . _log . error = debug ( 'ipfs:http-api:error' )
53+ this . _log = debug ( LOG )
54+ this . _log . error = debug ( LOG_ERROR )
5355
5456 if ( process . env . IPFS_MONITORING ) {
5557 // Setup debug metrics collection
@@ -147,7 +149,7 @@ class HttpApi {
147149 options : {
148150 prettyPrint : process . env . NODE_ENV !== 'production' ,
149151 logEvents : [ 'onPostStart' , 'onPostStop' , 'response' , 'request-error' ] ,
150- level : process . env . DEBUG ? 'debug' : 'error'
152+ level : debug . enabled ( LOG ) ? 'debug' : ( debug . enabled ( LOG_ERROR ) ? 'error' : 'fatal' )
151153 }
152154 } )
153155
@@ -183,9 +185,9 @@ class HttpApi {
183185 await server . register ( {
184186 plugin : Pino ,
185187 options : {
186- prettyPrint : Boolean ( process . env . DEBUG ) ,
188+ prettyPrint : Boolean ( debug . enabled ( LOG ) ) ,
187189 logEvents : [ 'onPostStart' , 'onPostStop' , 'response' , 'request-error' ] ,
188- level : process . env . DEBUG ? 'debug' : 'error'
190+ level : debug . enabled ( LOG ) ? 'debug' : ( debug . enabled ( LOG_ERROR ) ? 'error' : 'fatal' )
189191 }
190192 } )
191193
0 commit comments