From 50e68e404a3a16b39d42f2b0462cab94b03a05d3 Mon Sep 17 00:00:00 2001 From: gregor <gregor.schulz@holi.social> Date: Wed, 12 Mar 2025 16:08:58 +0100 Subject: [PATCH] improve logging --- app/fetch_event.ts | 8 +++----- app/fetch_events.ts | 4 ++-- app/server.ts | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/fetch_event.ts b/app/fetch_event.ts index 15d0d8e..b4e55ca 100644 --- a/app/fetch_event.ts +++ b/app/fetch_event.ts @@ -15,8 +15,6 @@ export type HoliEventResponse = { } export const toHoliEvent = (activity: Activity): HoliEvent | null => { - if (activity.period.permanent) return null - return { id: activity.id.toString(), title: activity.name, @@ -44,10 +42,10 @@ export const fetchEvent = async (input: FetchEventInput) => { const url = new URL(`${APP_API_BASE_URL}/activities/${input.id}`) const startDate = Date.now() - logger.info(`fetching event from ${url}`) + logger.debug(`fetching event from ${url}`) const response = await fetch(url) - if (response.status === 404) { + if (!response.ok) { throw new NotFound('Not found') } @@ -70,6 +68,6 @@ export const fetchEvent = async (input: FetchEventInput) => { throw e } finally { const duration = Date.now() - startDate - logger.debug(`fetching event took ${duration} ms`) + logger.info(`fetching event took ${duration} ms`) } } diff --git a/app/fetch_events.ts b/app/fetch_events.ts index e5439e8..7d915cc 100644 --- a/app/fetch_events.ts +++ b/app/fetch_events.ts @@ -107,7 +107,7 @@ const fetchEventsPage = async ( const startDate = Date.now() - logger.info(`fetching projects from ${url}`) + logger.debug(`fetching events from ${url}`) try { const response = await fetch(url, { // gregor: we don't need to send the api key to the App api @@ -133,7 +133,7 @@ const fetchEventsPage = async ( throw e } finally { const duration = Date.now() - startDate - logger.debug(`fetching projects took ${duration} ms`) + logger.info(`fetching projects took ${duration} ms`) } } diff --git a/app/server.ts b/app/server.ts index 51dfff1..8704cc2 100644 --- a/app/server.ts +++ b/app/server.ts @@ -56,6 +56,7 @@ export type EventRequest = { } const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput => { + logger.debug('validating request: ' + JSON.stringify(request)) return { limit: request.limit ?? 5, offset: request.offset ?? 0, @@ -64,7 +65,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput => } const validateEventRequestInput = (request: EventRequest): FetchEventInput => { - console.log(request) + logger.debug('validating request: ' + JSON.stringify(request)) return { id: request.id, } -- GitLab