Skip to content

Commit

Permalink
GoodGrind#14 Logger is introduced with different levels
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanCsore committed May 21, 2020
1 parent 00a1dab commit c1d9543
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/police-hu/police-hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export interface CrossingInfo {
outbound: QueueTime;
}

const loggerError = Pino({level: 'error', timestamp: stdTimeFunctions.isoTime, prettyPrint: true});
const loggerWarn = Pino({level: 'warn', timestamp: stdTimeFunctions.isoTime, prettyPrint: true});
const logger = Pino({timestamp: stdTimeFunctions.isoTime, prettyPrint: true});

export function infoUrlForCountry(country: Country): string {
return `${POLICE_HU_INFO_BASE_URL}${CROSSING_INFO_QUERY_PARAMS[country]}`;
Expand All @@ -63,7 +62,7 @@ export function extractLocationNames(crossingText: string): [string, string] {

// at this point, if we still don't have the expected number of segments something went wrong
if (crossingParts.length < EXPECTED_NUMBER_OF_NAME_SEGMENTS) {
loggerError.error(`Unable to parse crossing name for text: '${crossingText}'`);
logger.error(`Unable to parse crossing name for text: '${crossingText}'`);
throw new Error(`Unable to parse crossing name for text: '${text}'`);
}

Expand Down Expand Up @@ -99,7 +98,7 @@ export function extractWorkingHours(text: string): [string, string] {
const paddingWithZeroes = '0';

if (isNaN(openParsedToFloat) || isNaN(closeParsedToFloat)) {
loggerWarn.warn(`Working hours are not in the right format. Text '${text}' will be parsed to a standard ['00:00','00:00'] format.`);
logger.warn(`Working hours are not in the right format. Text '${text}' will be parsed to a standard ['00:00','00:00'] format.`);
return [
'00:00',
'00:00'
Expand Down

0 comments on commit c1d9543

Please sign in to comment.