File tree Expand file tree Collapse file tree 3 files changed +27
-29
lines changed
Expand file tree Collapse file tree 3 files changed +27
-29
lines changed Original file line number Diff line number Diff line change 11import path from "node:path" ;
22import { pathToFileURL } from "node:url" ;
33
4+ import pino from "pino" ;
5+ import pretty from "pino-pretty" ;
6+
47import { parseCliArgs , usageText } from "./cli-args" ;
58
9+ import { setLogger } from "@/shared/logger" ;
610import { startWatch } from "@/runtime/watch-runner" ;
711
12+ function createCliLogger ( ) {
13+ const stream = pretty ( {
14+ colorize : true ,
15+ sync : true ,
16+ translateTime : "SYS:HH:MM:ss" ,
17+ ignore : "pid,hostname" ,
18+ levelFirst : true ,
19+ } ) ;
20+
21+ return pino (
22+ {
23+ name : "snuts" ,
24+ level : process . env [ "LOG_LEVEL" ] ?? "info" ,
25+ } ,
26+ stream ,
27+ ) ;
28+ }
29+
830function writeOutput ( message : string , target : "stdout" | "stderr" ) : void {
931 const content = `${ message } \n` ;
1032
@@ -17,6 +39,8 @@ function writeOutput(message: string, target: "stdout" | "stderr"): void {
1739}
1840
1941export async function runCli ( argv : string [ ] ) : Promise < number > {
42+ setLogger ( createCliLogger ( ) ) ;
43+
2044 const parsedCommand = parseCliArgs ( argv ) ;
2145
2246 if ( parsedCommand . type === "help" ) {
Original file line number Diff line number Diff line change 1- import { createRequire } from "module" ;
2-
31import pino from "pino" ;
42
5- function hasPinoPretty ( ) : boolean {
6- try {
7- const require = createRequire ( process . cwd ( ) + "/index.js" ) ;
8- require . resolve ( "pino-pretty" ) ;
9- return true ;
10- } catch {
11- return false ;
12- }
13- }
14-
153/**
164 * Minimal logger interface used throughout the library.
175 * Matches the subset of pino's API that is actually called internally,
@@ -54,23 +42,9 @@ export const silentLogger: ILogger = {
5442} ;
5543
5644function createDefaultLogger ( ) : ILogger {
57- const isDev = process . env [ "NODE_ENV" ] !== "production" ;
58- const usePretty = isDev && hasPinoPretty ( ) ;
59-
6045 return pino ( {
61- name : "test-smell-watcher " ,
46+ name : "snuts " ,
6247 level : process . env [ "LOG_LEVEL" ] ?? "info" ,
63- transport : usePretty
64- ? {
65- target : "pino-pretty" ,
66- options : {
67- colorize : true ,
68- translateTime : "SYS:HH:MM:ss" ,
69- ignore : "pid,hostname" ,
70- levelFirst : true ,
71- } ,
72- }
73- : undefined ,
7448 } ) ;
7549}
7650
Original file line number Diff line number Diff line change 9494 "jest" : " ^29.7.0" ,
9595 "jest-environment-jsdom" : " ^29.7.0" ,
9696 "lint-staged" : " ^16.2.4" ,
97- "pino-pretty" : " ^13.1.2" ,
9897 "prettier" : " ^3.6.2" ,
9998 "rimraf" : " ^6.0.1" ,
10099 "ts-jest" : " ^29.2.0" ,
111110 "esquery" : " ^1.6.0" ,
112111 "glob" : " ^11.0.3" ,
113112 "lodash" : " ^4.17.21" ,
114- "pino" : " ^10.1.0"
113+ "pino" : " ^10.1.0" ,
114+ "pino-pretty" : " ^13.1.2"
115115 }
116116}
You can’t perform that action at this time.
0 commit comments