Skip to content

Commit

Permalink
address PR comments and align logType to level
Browse files Browse the repository at this point in the history
  • Loading branch information
metal-messiah committed Jun 25, 2024
1 parent cc5b9cc commit bddee8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/content/docs/browser/new-relic-browser/browser-apis/log.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Captures data as a single log event.

## Description

Upon executing this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`.
When you execute this function with a valid message and elective options, the browser agent records the data as a single `log` event. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on the log event. You can control the `level` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`.

## Parameters

Expand Down Expand Up @@ -78,7 +78,7 @@ Upon executing this function with a valid message and elective options, the brow
</td>

<td>
Optional. An object used for supplying optional configurations for the captured log. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied.
Optional. An object used for supplying optional configurations for the captured log. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. The enum `options.level` assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied.
</td>
</tr>
</tbody>
Expand All @@ -92,16 +92,16 @@ Upon executing this function with a valid message and elective options, the brow
newrelic.log('my log message')
// saves a log event with:
// a message of --> 'my log message'
// a logType of --> 'info'
// a level of --> 'info'
```

### Capturing a log item with a specified logType
### Capturing a log item with a specified level

```js
newrelic.log('my log message', {level: 'debug'})
// saves a log event with:
// a message of --> 'my log message'
// a logType of --> 'debug'
// a level of --> 'debug'
```

### Capturing a log item with custom attributes
Expand All @@ -110,16 +110,16 @@ newrelic.log('my log message', {level: 'debug'})
newrelic.log('my log message', {customAttributes: {myFavoriteApp: true}})
// saves a log event with:
// a message of --> 'my log message'
// a logType of --> 'info'
// a level of --> 'info'
// an attribute of --> 'myFavoriteApp: true'
```

### Capturing a log item with a specified logType and custom attributes
### Capturing a log item with a specified level and custom attributes

```js
newrelic.log('my log message', {level: 'debug', customAttributes: {myFavoriteApp: true}})
// saves a log event with:
// a message of --> 'my log message'
// a logType of --> 'debug'
// a level of --> 'debug'
// an attribute of --> 'myFavoriteApp: true'
```
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ To report errors in your application, use these methods:

<tr>
<td>
Capture a caught or handled error, without disrupting your app's operation
Capture a caught or handled error without disrupting your app's operation
</td>

<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Automatically captures data passing through existing browser logging methods as
For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent).

## Description
Upon providing this method with a valid parent container and child function name, the browser agent will record a new `log` event every time the wrapped function is `invoked`, capturing the `first` argument passed to the invoked function as the log's `message`. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events. Optional configurations can be passed along with these captured logs, by use of the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `logType` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. **Note** once successfully wrapped, the function's logging detection will not be able to be altered.
After you provide this method with a valid parent container and child function name, the browser agent will record a new log event every time the wrapped function is invoked. The first argument is passed to the invoked function as the log's message. See the [Logs UI](https://docs.newrelic.com/docs/logs/ui-data/use-logs-ui/) for more information about log events.

Optional configurations can be passed along with these captured logs with the `options` argument. Any custom attributes supplied to the API call in the `options` argument (`options.customAttributes`) will be appended as top-level attributes on every log event created by this wrapper. You can control the `level` of the captured log by supplying a `level` to the `options` argument (`options.level`), which defaults to `info`. Note that once successfully wrapped, the function's logging detection can't be altered.

## Parameters

Expand Down Expand Up @@ -88,7 +90,7 @@ Upon providing this method with a valid parent container and child function name
</td>

<td>
Optional. An object used for supplying optional configurations for every log captured by the wrapper. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. `options.level` is an enum that assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied.
Optional. An object used for supplying optional configurations for every log captured by the wrapper. `options.customAttributes` is an object of key:val pairs that assigns a top-level property and value to the created log for each attribute supplied. The enum `options.level` assigns a log level to the created log event. The `level` must be one of: `debug | error | info | trace | warn`. The log level defaults to `info` if not supplied.
</td>
</tr>
</tbody>
Expand All @@ -101,7 +103,7 @@ Upon providing this method with a valid parent container and child function name
newrelic.wrapLogger(console, 'info')
// from this point forward, every time `console.info` is invoked, it will save a log event with:
// a message of --> <the first argument passed to console.info>
// a logType of --> 'info'
// a level of --> 'info'
```

### Capturing log items from a custom logger
Expand All @@ -113,10 +115,10 @@ const myLoggers = {
newrelic.wrapLogger(myLoggers, 'logger')
// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with:
// a message of --> <the first argument passed to myLoggers.logger>
// a logType of --> 'info'
// a level of --> 'info'
```
### Capturing log items with a specified logType
### Capturing log items with a specified level
```js
const myLoggers = {
Expand All @@ -125,7 +127,7 @@ const myLoggers = {
newrelic.wrapLogger(myLoggers, 'logger', {level: 'debug'})
// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with:
// a message of --> <the first argument passed to myLoggers.logger>
// a logType of --> 'debug'
// a level of --> 'debug'
```
### Capturing a log item with custom attributes
Expand All @@ -137,7 +139,7 @@ const myLoggers = {
newrelic.wrapLogger(myLoggers, 'logger', {customAttributes: {myFavoriteApp: true}})
// from this point forward, every time `myLoggers.logger` is invoked, it will save a log event with:
// a message of --> <the first argument passed to myLoggers.logger>
// a logType of --> 'info'
// a level of --> 'info'
// an attribute of --> 'myFavoriteApp: true'
```
Expand All @@ -152,9 +154,9 @@ newrelic.wrapLogger(myLoggers, 'myInfoLogger', {level: 'info'})
newrelic.wrapLogger(myLoggers, 'myDebugLogger', {level: 'debug'})
// from this point forward, every time `myLoggers.myInfoLogger` is invoked, it will save a log event with:
// a message of --> <the first argument passed to myLoggers.myInfoLogger>
// a logType of --> 'info'
// a level of --> 'info'

// every time `myLoggers.myDebugLogger` is invoked, it will save a log event with:
// a message of --> <the first argument passed to myLoggers.myDebugLogger>
// a logType of --> 'debug'
// a level of --> 'debug'
```

0 comments on commit bddee8e

Please sign in to comment.