melhoria de log

This commit is contained in:
Luiz H. R. Silva 2024-06-13 12:12:04 -03:00
parent 6e9b668af9
commit 3473a5b4ec
3 changed files with 25 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import { gerar } from "./listar_arquivos";
import React, {} from "react"; import React, {} from "react";
import fastifyStatc from "@fastify/static"; import fastifyStatc from "@fastify/static";
import dayjs from "dayjs";
import Fastify, {} from "fastify"; import Fastify, {} from "fastify";
const { PORTA, PREFIXO } = ambiente; const { PORTA, PREFIXO } = ambiente;
@ -57,10 +58,23 @@ const criarHtml = (entrada: {
gerar.then(() => { gerar.then(() => {
const fastify = Fastify({ const fastify = Fastify({
logger: true, logger: false,
ignoreTrailingSlash: true, ignoreTrailingSlash: true,
}); });
fastify.addHook("onSend", async (request, reply) => {
console.log(
[
dayjs().format("YYYY-MM-DD HH:mm:ss"),
request.method,
request.url,
reply.statusCode,
request.headers.site || request.headers.referer,
].join(" "),
);
});
//cors //cors
fastify.register(cors, { fastify.register(cors, {
origin: "*", origin: "*",

View file

@ -1,6 +1,6 @@
{ {
"name": "p-estaticos", "name": "p-estaticos",
"version": "0.40.0", "version": "0.41.0",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
@ -21,6 +21,7 @@
"dependencies": { "dependencies": {
"@fastify/cors": "^9.0.1", "@fastify/cors": "^9.0.1",
"@fastify/static": "^7.0.4", "@fastify/static": "^7.0.4",
"dayjs": "^1.11.11",
"fastify": "^4.27.0", "fastify": "^4.27.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",

8
pnpm-lock.yaml generated
View file

@ -14,6 +14,9 @@ importers:
'@fastify/static': '@fastify/static':
specifier: ^7.0.4 specifier: ^7.0.4
version: 7.0.4 version: 7.0.4
dayjs:
specifier: ^1.11.11
version: 1.11.11
fastify: fastify:
specifier: ^4.27.0 specifier: ^4.27.0
version: 4.27.0 version: 4.27.0
@ -248,6 +251,9 @@ packages:
csstype@3.1.3: csstype@3.1.3:
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
dayjs@1.11.11:
resolution: {integrity: sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==}
depd@2.0.0: depd@2.0.0:
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
engines: {node: '>= 0.8'} engines: {node: '>= 0.8'}
@ -831,6 +837,8 @@ snapshots:
csstype@3.1.3: {} csstype@3.1.3: {}
dayjs@1.11.11: {}
depd@2.0.0: {} depd@2.0.0: {}
dotenv-cli@7.4.1: dotenv-cli@7.4.1: