File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ import { createRequire } from "module" ;
2+
13import pino from "pino" ;
24
5+ function hasPinoPretty ( ) : boolean {
6+ try {
7+ const require = createRequire ( import . meta. url ) ;
8+ require . resolve ( "pino-pretty" ) ;
9+ return true ;
10+ } catch {
11+ return false ;
12+ }
13+ }
14+
315/**
416 * Minimal logger interface used throughout the library.
517 * Matches the subset of pino's API that is actually called internally,
@@ -43,11 +55,12 @@ export const silentLogger: ILogger = {
4355
4456function createDefaultLogger ( ) : ILogger {
4557 const isDev = process . env [ "NODE_ENV" ] !== "production" ;
58+ const usePretty = isDev && hasPinoPretty ( ) ;
4659
4760 return pino ( {
4861 name : "test-smell-watcher" ,
4962 level : process . env [ "LOG_LEVEL" ] ?? "info" ,
50- transport : isDev
63+ transport : usePretty
5164 ? {
5265 target : "pino-pretty" ,
5366 options : {
You can’t perform that action at this time.
0 commit comments