Skip to content

Commit

Permalink
docs: add running and debugging pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes Lin authored and agnes512 committed May 6, 2020
1 parent c55f4b0 commit a41652b
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/site/Running-debugging-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: 'Running and debugging apps'
lang: en
keywords: LoopBack 4.0, LoopBack 4, Debug
sidebar: lb4_sidebar
permalink: /doc/en/lb4/Running-and-debugging-apps.html
summary:
---

In general, when you are developing an application, use the `npm` command to run
it. This enables you to see stack traces and console output immediately.

For example:

```
$ cd myapp
$ npm start
```

LoopBack 4 also allows you to specify debug strings that the application will
display to the console (or save to a file) to help you verify or diagnose the
app. See [Setting debug strings](Setting-debug-strings.md).
329 changes: 329 additions & 0 deletions docs/site/Setting-debug-strings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
---
title: 'Setting debug strings'
lang: en
keywords: LoopBack 4.0, LoopBack 4, base-connector.js
sidebar: lb4_sidebar
permalink: /doc/en/lb4/Setting-debug-strings.html
summary:
---

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

LoopBack 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:

**MacOS and Linux**

```shell
$ DEBUG=<pattern>[,<pattern>...] npm start
```

**Windows**

```shell
C:\> set DEBUG=<pattern>[,<pattern>...]
C:\> npm start
```

where &lt;_pattern_&gt; is a string-matching pattern specifying debug strings to
match. You can specify as many matching patterns as you wish.

For example (MacOS and Linux):

```shell
$ DEBUG=loopback:datasource npm start
```

Or, on Windows:

```shell
C:\> set DEBUG=loopback:datasource
C:\> npm start
```

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":

```shell
$ DEBUG=*oracle npm start
```

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

## Debug string format

These strings have the format

`module[:area]:string`

Where:

- _module_ is the name of the module, for example `loopback` or
`loopback-connector-mongodb`.
- _area_ is an optional identifier such as `cli` or `repository` to identify the
purpose of the module
- _string_ is the debug string specified in the target TypeScript/JavaScript
source file, such as `application.ts`.

For example:

`loopback:cli:model-generator`

The debug string `model-generator` is specified in the source file
[`generators/model/index.js`](https://github.com/strongloop/loopback-next/blob/master/packages/cli/generators/model/index.js)
of the `@loopback/cli` module.

## Debug strings reference

<table>
<tbody>
<tr>
<th width="240">Module</th>
<th width="330">Source file</th>
<th width="330">String</th>
</tr>
<tr>
<th colspan="2">@loopback</th>
</tr>
<tr>
<td>@loopback/authorization</td>
<td>src/authorize-interceptor.ts</td>
<td>loopback:authorization:interceptor</td>
</tr>
<tr>
<td>@loopback/boot</td>
<td>src/bootstrapper.ts</td>
<td>loopback:boot:bootstrapper</td>
</tr>
<tr>
<td></td>
<td>src/booters/interceptor.booter.ts</td>
<td>loopback:boot:interceptor-booter</td>
</tr>
<tr>
<td></td>
<td>src/booters/lifecycle-observer.booter.ts</td>
<td>loopback:boot:lifecycle-observer-booter</td>
</tr>
<tr>
<td></td>
<td>src/booters/model-api.booter.ts</td>
<td>loopback:boot:model-api</td>
</tr>
<tr>
<td></td>
<td>src/booters/service.booter.ts</td>
<td>loopback:boot:service-booter</td>
</tr>
<tr>
<td>@loopback/booter-lb3app</td>
<td>src/lb3app.booter.ts</td>
<td>loopback:boot:lb3app</td>
</tr>
<tr>
<td>@loopback/cron</td>
<td>src/cron.component.ts</td>
<td>loopback:cron</td>
</tr>
<tr>
<td>@loopback/rest-crud</td>
<td>src/crud-rest-builder.ts</td>
<td>loopback:boot:crud-rest</td>
</tr>
<tr>
<td>@loopback/cli</td>
<td>please check each generator</td>
<td>loopback:cli:_string_</td>
</tr>
<tr>
<td>@loopback/context</td>
<td>src/interceptor.ts</td>
<td>loopback:context:interceptor</td>
</tr>
<tr>
<td></td>
<td>src/binding.ts</td>
<td>loopback:context:bindging</td>
</tr>
<tr>
<td></td>
<td>src/context-view.ts</td>
<td>loopback:context:view</td>
</tr>
<tr>
<td></td>
<td>src/invocation.ts</td>
<td>loopback:context:invocation</td>
</tr>
<tr>
<td></td>
<td>src/interceptor-chain.ts</td>
<td>loopback:context:interceptor-chain</td>
</tr>
<tr>
<td>@loopback/http-caching-proxy</td>
<td>src/http-caching-proxy.ts</td>
<td>loopback:http-caching-proxy</td>
</tr>
<tr>
<td>@loopback/core</td>
<td>src/lifecycle-registry.ts</td>
<td>loopback:core:lifecycle</td>
</tr>
<tr>
<td></td>
<td>src/application.ts</td>
<td>loopback:core:application</td>
</tr>
<tr>
<td>@loopback/openapi-v3</td>
<td>src/<sup>&#42;</sup></td>
<td>loopback:openapi</td>
</tr>
<tr>
<td>@loopback/repository</td>
<td>src/relations/belongs-to/belongs-to-accessor.ts</td>
<td>loopback:repository:belongs-to-accessor</td>
</tr>
<tr>
<td></td>
<td>src/relations/has-many/has-many-repository-factory.ts</td>
<td>loopback:repository:has-many-repository-factory</td>
</tr>
<tr>
<td></td>
<td>src/relations/has-one/has-one-repository-factory.ts</td>
<td>loopback:repository:has-one-repository-factory</td>
</tr>
<tr>
<td>@loopback/repository-json-schema</td>
<td>src/build-schema.ts</td>
<td>loopback:repository-json-schema:build-schema</td>
</tr>
<tr>
<td>@loopback/rest</td>
<td>src/rest-server/</td>
<td>loopback:rest:server</td>
</tr>
<tr>
<td></td>
<td>src/sequence.ts</td>
<td>loopback:rest:sequence</td>
</tr>
<tr>
<th colspan="2"><span>loopback-datasource-juggler</span></th>
</tr>
<tr>
<td></td>
<td>lib/datasource.js</td>
<td>loopback:datasource</td>
</tr>
<tr>
<th colspan="2">Connectors</th>
</tr>
<tr>
<td>loopback-connector</td>
<td>lib/connector.js</td>
<td>loopback:connector</td>
</tr>
<tr>
<td>loopback-connector-cassandra</td>
<td>lib/cassandra.js</td>
<td>loopback:connector:cassandra</td>
</tr>
<tr>
<td>loopback-connector-cloudant</td>
<td>lib/cloudant.js</td>
<td>loopback:connector:cloudant</td>
</tr>
<tr>
<td>loopback-connector-couchdb2</td>
<td>lib/couchdb2.js</td>
<td>loopback:connector:couchdb2</td>
</tr>
<tr>
<td>loopback-connector-dashdb</td>
<td>lib/dashdb.js</td>
<td>loopback:connector:dashdb</td>
</tr>
<tr>
<td>loopback-connector-db2</td>
<td>lib/db2.js</td>
<td>loopback:connector:db2</td>
</tr>
<tr>
<td>loopback-connector-ibmi</td>
<td>lib/ibmiconnector.js</td>
<td>loopback:connector:ibmiconnector</td>
</tr>
<tr>
<td>loopback-connector-kv-redis</td>
<td>lib/kv-redis.js</td>
<td>loopback:connector:kv-redis</td>
</tr>
<tr>
<td>loopback-connector-mongodb</td>
<td>lib/mongodb.js</td>
<td>loopback:connector:mongodb</td>
</tr>
<tr>
<td>loopback-connector-mssql</td>
<td>lib/mssql.js</td>
<td>loopback:connector:mssql</td>
</tr>
<tr>
<td>loopback-connector-mysql</td>
<td>lib/mysql.js</td>
<td>loopback:connector:mysql</td>
</tr>
<tr>
<td>loopback-connector-oracle</td>
<td>lib/oracle.js</td>
<td>loopback:connector:oracle</td>
</tr>
<tr>
<td>loopback-connector-postgresql</td>
<td>lib/postgresql.js</td>
<td>loopback:connector:postgresql</td>
</tr>
<tr>
<td>loopback-connector-rest</td>
<td>lib/rest-builder.js</td>
<td>loopback:connector:rest</td>
</tr>
<tr>
<td></td>
<td>lib/rest-connector.js</td>
<td>loopback:connector:rest</td>
</tr>
<tr>
<td></td>
<td>lib/rest-model.js</td>
<td>loopback:connector:rest</td>
</tr>
<tr>
<td></td>
<td>lib/swagger-client.js</td>
<td>loopback:connector:rest:swagger</td>
</tr>
<tr>
<td>loopback-connector-soap</td>
<td>lib/soap-connector.js</td>
<td>loopback:connector:soap</td>
</tr>
</tbody>
</table>
9 changes: 9 additions & 0 deletions docs/site/sidebars/lb4_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ children:
url: Database-migrations.html
output: 'web, pdf'

- title: 'Running and debugging apps'
url: Running-and-debugging-apps.html
output: 'web, pdf'
children:

- title: 'Setting debug strings'
url: Setting-debug-strings.html
output: 'web, pdf'

- title: 'Call Other Services'
url: Calling-other-APIs-and-web-services.html
output: 'web, pdf'
Expand Down

0 comments on commit a41652b

Please sign in to comment.