Add fluentd

pull/1645/head
Fernando Gabriel Sarmiento Diaz 2022-11-09 14:59:04 +09:00
parent 3bca3ef072
commit f4d52fcd98
4 changed files with 26 additions and 1 deletions

11
lib/logger.js Normal file
View File

@ -0,0 +1,11 @@
import { FluentClient } from '@fluent-org/logger';
const logger = new FluentClient(process.env.FLUENT_TAG_PREFIX, {
socket: {
host: process.env.FLUENTD_HOST,
port: process.env.FLUENTD_PORT,
timeout: 3000, // 3 seconds
},
});
export default logger;

View File

@ -12,6 +12,7 @@ import {
LAPTOP_SCREEN_WIDTH,
MOBILE_SCREEN_WIDTH,
} from './constants';
import logger from './logger';
let lookup;
@ -75,7 +76,7 @@ export async function getCountry(req, ip) {
const result = lookup.get(ip);
console.log(JSON.stringify(result));
logger.emit('getCountry', { result });
return result?.country?.iso_code;
}

View File

@ -56,6 +56,7 @@
]
},
"dependencies": {
"@fluent-org/logger": "^1.0.10",
"@fontsource/inter": "4.5.7",
"@prisma/client": "^4.4.0",
"chalk": "^4.1.1",

View File

@ -1141,6 +1141,13 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"
"@fluent-org/logger@^1.0.10":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@fluent-org/logger/-/logger-1.0.10.tgz#b90a4c8cf6ead0819bf86f47ee4b268d2ee70b88"
integrity sha512-7gWfwknDWlcvh92sbUGj1pbGyKwkprfNH2ZuFTgCBQLQmcexvFEYh70z69S/TLnQ6z9sqpgfT/gyHrudBqRtZg==
dependencies:
"@msgpack/msgpack" "^2.7.1"
"@fontsource/inter@4.5.7":
version "4.5.7"
resolved "https://registry.npmjs.org/@fontsource/inter/-/inter-4.5.7.tgz"
@ -1347,6 +1354,11 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@msgpack/msgpack@^2.7.1":
version "2.8.0"
resolved "https://registry.yarnpkg.com/@msgpack/msgpack/-/msgpack-2.8.0.tgz#4210deb771ee3912964f14a15ddfb5ff877e70b9"
integrity sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==
"@next/env@12.2.5":
version "12.2.5"
resolved "https://registry.yarnpkg.com/@next/env/-/env-12.2.5.tgz#d908c57b35262b94db3e431e869b72ac3e1ad3e3"