Skip to content

Commit

Permalink
Updating readme and testing a console log
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Dec 30, 2024
1 parent 79bf093 commit 0b3bb7b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,51 @@ $ npm run lint

## Logging

This project uses Winston for serverside logging, and New Relic for clientside logging. Serverside logs for this project's `qa` and `production` branches can be found in AWS Cloudwatch under the nypl-dams-dev and nypl-dams-prod accounts, and clientside logs can be found in New Relic (Digital Collections (prod/qa) > Browser > errors). For Vercel deployments, logging will appear in the console.
### Where do I find logs?

Serverside logs for this project's `qa` and `production` branches can be found in AWS Cloudwatch under the `nypl-dams-dev` and `nypl-dams-prod` accounts.

Clientside _errors_ can be found in New Relic under `Facelift production or Facelift QA > Browser > Errors`.

Clientside _logs_ can be found under `Facelift production or Facelift QA > Browser > Logs`.

Serverside logs also appear in New Relic under APM Logs and general Logs (query "facelift").

For Vercel deployments, logging will appear in the console.

### How do I add logs?

We structure our logs according to these [NYPL standards](https://github.com/NYPL/engineering-general/blob/main/standards/logging.md). See `logger.js` for the formatting and storage of logs.

Do NOT use `console.log` if you want to add a permanent log, and make sure to clean up your debugging `console.log`s, because they will clutter Cloudwatch and New Relic.
You SHOULD NOT use `console.log` if you want to add a _permanent_ log, and make sure to clean up your debugging `console.log`s, because they will clutter Cloudwatch and New Relic.

On the server side, you SHOULD use `logger.[some NYPL log level](message: string)`.

On the client side, we already use an error boundary (`error.tsx`) to handle uncaught exceptions, which sends errors to New Relic like this:

```
useEffect(() => {
if ((window as any).newrelic) {
(window as any).newrelic.noticeError(error);
}
}, [error]);
```

If you want to add other client side _errors_, you SHOULD use `newrelic.noticeError(message: string)` as above.

If you want to add a client side _log_, you SHOULD use `newrelic.log(message: string, {level: 'debug|error|info|trace|warn'})`, for example:

```
useEffect(() => {
if ((window as any).newrelic) {
(window as any).newrelic.log("Test log at info level", {
level: "info",
});
}
}, []);
```

On the server side, DO use `logger.[some NYPL log level](message: string)`.
On the client side...
New Relic logs need to be in a `useEffect` because we have to check that New Relic is enabled in the window.

## Github Actions

Expand Down
1 change: 1 addition & 0 deletions app/src/components/pages/divisionsPage/divisionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function DivisionsPage({ summary, divisions }: DivisionsProps) {

useEffect(() => {
setIsLoaded(true);
console.log("Does this go to NR");
}, []);

return (
Expand Down

0 comments on commit 0b3bb7b

Please sign in to comment.