92feb76252
And also make a proposed split of how the loggers are handled.
Now logs look like
```
{
"type": "incomingRequest",
"service": "backstage",
"timestamp": "2020-04-30T14:29:04.002Z",
"message": "...",
"level": "info"
}
```
for requests, and then if the plugin logs something properly
```
{
"type": "plugin",
"service": "backstage",
"plugin": "inventory",
"timestamp": "2020-04-30T14:29:04.002Z",
"message": "...",
"level": "info"
}
```
846 B
846 B
@backstage/backend-common
Common functionality library for Backstage backends, implementing logging, error handling and similar.
Usage
Add the library to your backend package:
yarn add @backstage/backend-common
then make use of the handlers and logger as necessary:
import {
errorHandler,
getRootLogger,
notFoundHandler,
requestLoggingHandler,
} from '@backstage/backend-common';
const app = express();
app.use(requestLoggingHandler());
app.use('/home', myHomeRouter);
app.use(notFoundHandler());
app.use(errorHandler());
app.listen(PORT, () => {
getRootLogger().info(`Listening on port ${PORT}`);
});