Skip to content

Commit f94eb93

Browse files
switch logging to pino (#62)
* Use application logger in eppo-client.ts * export logger
1 parent d271ac6 commit f94eb93

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/client/eppo-client.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { logger } from '../application-logger';
12
import {
23
AssignmentCache,
34
Cacheable,
@@ -307,7 +308,7 @@ export default class EppoClient implements IEppoClient {
307308

308309
private rethrowIfNotGraceful(err: Error, defaultValue?: EppoValue): EppoValue {
309310
if (this.isGracefulFailureMode) {
310-
console.error(`[Eppo SDK] Error getting assignment: ${err.message}`);
311+
logger.error(`[Eppo SDK] Error getting assignment: ${err.message}`);
311312
return defaultValue ?? EppoValue.Null();
312313
}
313314
throw err;
@@ -338,7 +339,7 @@ export default class EppoClient implements IEppoClient {
338339
const flag = this.getFlag(flagKey);
339340

340341
if (flag === null) {
341-
console.warn(`[Eppo SDK] No assigned variation. Flag not found: ${flagKey}`);
342+
logger.warn(`[Eppo SDK] No assigned variation. Flag not found: ${flagKey}`);
342343
// note: this is different from the Python SDK, which returns None instead
343344
return noneResult(flagKey, subjectKey, subjectAttributes);
344345
}
@@ -350,7 +351,7 @@ export default class EppoClient implements IEppoClient {
350351
}
351352

352353
if (!flag.enabled) {
353-
console.info(`[Eppo SDK] No assigned variation. Flag is disabled: ${flagKey}`);
354+
logger.info(`[Eppo SDK] No assigned variation. Flag is disabled: ${flagKey}`);
354355
// note: this is different from the Python SDK, which returns None instead
355356
return noneResult(flagKey, subjectKey, subjectAttributes);
356357
}
@@ -375,7 +376,7 @@ export default class EppoClient implements IEppoClient {
375376
this.logAssignment(result);
376377
}
377378
} catch (error) {
378-
console.error(`[Eppo SDK] Error logging assignment event: ${error}`);
379+
logger.error(`[Eppo SDK] Error logging assignment event: ${error}`);
379380
}
380381

381382
return result;
@@ -445,7 +446,7 @@ export default class EppoClient implements IEppoClient {
445446
this.assignmentLogger?.logAssignment(event);
446447
}
447448
} catch (error) {
448-
console.error(`[Eppo SDK] Error flushing assignment events: ${error.message}`);
449+
logger.error(`[Eppo SDK] Error flushing assignment events: ${error.message}`);
449450
}
450451
}
451452

@@ -493,7 +494,7 @@ export default class EppoClient implements IEppoClient {
493494
variationKey: result.variation?.key ?? '__eppo_no_variation',
494495
});
495496
} catch (error) {
496-
console.error(`[Eppo SDK] Error logging assignment event: ${error.message}`);
497+
logger.error(`[Eppo SDK] Error logging assignment event: ${error.message}`);
497498
}
498499
}
499500
}

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { logger } from './application-logger';
12
import { AssignmentCache } from './assignment-cache';
23
import { IAssignmentHooks } from './assignment-hooks';
34
import { IAssignmentLogger, IAssignmentEvent } from './assignment-logger';
@@ -12,6 +13,7 @@ import { AttributeType, SubjectAttributes } from './types';
1213
import * as validation from './validation';
1314

1415
export {
16+
logger as applicationLogger,
1517
IAssignmentHooks,
1618
IAssignmentLogger,
1719
IAssignmentEvent,

0 commit comments

Comments
 (0)