ignore, logs

This commit is contained in:
2026-01-24 15:02:44 -03:00
parent 92c8d76b60
commit 17bb8a15fe
3 changed files with 8 additions and 6 deletions

View File

@@ -5,11 +5,13 @@ const filename = 'logs.csv',
console.log(filename, fileExist);
if (!fileExist) appendFileSync(filename, ['Date', 'Method', 'Url', 'Status'].join(',') + '\n', 'utf8');
if (!fileExist) appendFileSync(filename, ['Date', 'Method', 'Domain', 'Path', 'Status'].join(',') + '\n', 'utf8');
export const log = (method: string, url: string, status: number) => {
appendFileSync(filename, [isoDateInTimeZone(), method, url, status].join(',') + '\n', 'utf8');
}
export const log = (method: string, response: Response) => {
const { url, status } = response,
{ host, pathname } = new URL(url);
appendFileSync(filename, [isoDateInTimeZone(), method, host, pathname, status].join(',') + '\n', 'utf8');
};
function isoDateInTimeZone(timeZone = 'America/Buenos_Aires', date = new Date()) {
const parts = new Intl.DateTimeFormat("en-CA", {