mirror of
https://github.com/sergeyyarkov/modbus-logger.git
synced 2026-10-11 10:28:51 +03:00
put logger into config file
This commit is contained in:
parent
82d8976ee3
commit
fdc195d7dd
15
app/index.js
15
app/index.js
@ -1,5 +1,5 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import pino from "pino-http";
|
import httpLogger from "#root/config/logger.config.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routers
|
* Routers
|
||||||
@ -13,18 +13,7 @@ import { errorHandlerMiddleware } from "#root/middlewares/index.js";
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(
|
app.use(httpLogger);
|
||||||
pino(
|
|
||||||
process.env.NODE_ENV === "development" && {
|
|
||||||
transport: {
|
|
||||||
target: "pino-pretty",
|
|
||||||
options: {
|
|
||||||
colorize: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(express.static("public"));
|
app.use(express.static("public"));
|
||||||
app.use("/api", apiRouter);
|
app.use("/api", apiRouter);
|
||||||
|
|||||||
12
config/logger.config.js
Normal file
12
config/logger.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import pino from "pino-http";
|
||||||
|
|
||||||
|
export default pino(
|
||||||
|
process.env.NODE_ENV === "development" && {
|
||||||
|
transport: {
|
||||||
|
target: "pino-pretty",
|
||||||
|
options: {
|
||||||
|
colorize: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
Loading…
x
Reference in New Issue
Block a user