Chinese Documentation : Setting debug strings

See also: Operating Node applications (slc), comes with a built in debugger, Node Inspector that you can use to debug a running application; see Debugging applications for more information.

You can specify debug strings when you run an application, as explained below, to display specific log output to the console.  You can also redirect the output to a file, if desired.  These techniques are often helpful in debugging applications.

Using debug strings

The LoopBack framework has a number of built-in debug strings to help with debugging.  Specify a string on the command-line via an environment variable as follows:

$ DEBUG=<pattern>[,<pattern>...] slc run

where <pattern> is a string-matching pattern specifying debug strings to match. You can specify as many matching patterns as you wish.

For example:

$ DEBUG=loopback:datasource slc run

You'll see output such as (truncated for brevity):

loopback:datasource Settings: {"name":"db","debug":true} +0ms
loopback:datasource Settings: {"name":"geo","connector":"rest",...

You can use an asterisk  (*) in the pattern to match any string.  For example the following would match any debug string containing "oracle":

$ DEBUG=*oracle slc run

You can also exclude specific debuggers by prefixing them with a "-" character. For example, DEBUG=*,-strong-remoting:* would include all debuggers except those starting with "strong-remoting:".

Debug string format

These strings have the format

module[:area]:fileName

Where

  • module is the name of the module, for example loopback or loopback-connector-rest.
  • area is an optional identifier such as security or connector to identify the purpose of the module
  • fileName is the name of the JavaScript source file, such as oracle.js.

For example

loopback:security:access-context

identifies the source file access-context.js in the loopback module (used for security features).

Debug strings reference

Module / Source fileString
loopback
loopback/lib/connectors/base-connector.jsconnector
loopback/lib/connectors/mail.jsloopback:connector:mail
loopback/lib/connectors/memory.jsmemory
loopback/lib/models/access-context.jsloopback:security:access-context
loopback/lib/models/acl.jsloopback:security:acl
loopback/lib/models/change.jsloopback:change
loopback/lib/models/role.jsloopback:security:role
loopback/lib/models/user.jsloopback:user
loopback-datasource-juggler
loopback-datasource-juggler/lib/datasource.jsloopback:datasource
loopback-boot
loopback-boot/lib/compiler.jsloopback:boot:compiler
loopback-boot/lib/executor.jsloopback:boot:executor
Components
loopback-component-push/lib/providers/apns.jsloopback:component:push:provider:apns
loopback-component-push/lib/providers/gcm.jsloopback:component:push:provider:gcm
loopback-component-push/lib/push-manager.jsloopback:component:push:push-manager
Connectors
loopback-connector-mongodb/lib/mongodb.jsloopback:connector:mongodb
loopback-connector-mssql/example/datagraph.jsdatagraph
loopback-connector-mssql/lib/mssql.jsloopback:connector:mssql
loopback-connector-mysql/lib/mysql.jsloopback:connector:mysql
loopback-connector-oracle/lib/oracle.jsloopback:connector:oracle
loopback-connector-postgresql/lib/postgresql.jsloopback:connector:postgresql
loopback-connector-rest/lib/rest-builder.jsloopback:connector:rest
loopback-connector-rest/lib/rest-connector.jsloopback:connector:rest
loopback-connector-rest/lib/rest-model.jsloopback:connector:rest
loopback-connector-rest/lib/swagger-client.jsloopback:connector:rest:swagger
loopback-connector-soap/lib/soap-connector.jsloopback:connector:soap
strong-remoting
strong-remoting/lib/dynamic.jsstrong-remoting:dynamic
strong-remoting/lib/exports-helper.jsstrong-remoting:exports-helper
strong-remoting/lib/http-context.jsstrong-remoting:http-context
strong-remoting/lib/http-invocation.jsstrong-remoting:http-invocation
strong-remoting/lib/jsonrpc-adapter.jsstrong-remoting:jsonrpc-adapter
strong-remoting/lib/remote-objects.jsstrong-remoting:remotes
strong-remoting/lib/rest-adapter.jsstrong-remoting:rest-adapter
strong-remoting/lib/shared-class.jsstrong-remoting:shared-class
strong-remoting/lib/shared-method.jsstrong-remoting:shared-method
strong-remoting/lib/socket-io-adapter.jsstrong-remoting:socket-io-adapter
strong-remoting/lib/socket-io-context.jsstrong-remoting:socket-io-context
loopback-explorer
loopback-explorer/lib/route-helper.jsloopback:explorer:routeHelpers
loopback-workspace
loopback-workspace/connector.jsworkspace:connector
loopback-workspace/connector.jsworkspace:connector:save-sync
loopback-workspace/models/config-file.jsworkspace:config-file
loopback-workspace/models/definition.jsworkspace:definition
loopback-workspace/models/facet.jsworkspace:facet
loopback-workspace/models/facet.js:var workspace:facet:load: + facetName
loopback-workspace/models/facet.js:var workspace:facet:save: + facetName
loopback-workspace/models/workspace.jsworkspace