Commit 0a2cf6c

Anton Golub <antongolub@antongolub.com>
2022-09-18 21:54:42
docs: add custom logger example (#515)
closes #509
1 parent 3905ecf
Changed files (1)
README.md
@@ -350,7 +350,22 @@ all `$` processes use `process.cwd()` by default (same as `spawn` behavior).
 
 ### `$.log`
 
-Specifies a [logging function](src/log.ts).
+Specifies a [logging function](src/core.ts).
+
+```ts
+import { LogEntry, log } from 'zx/core'
+
+$.log = (entry: LogEntry) => {
+  switch (entry.kind) {
+    case 'cmd':
+      // for example, apply custom data masker for cmd printing
+      process.stderr.write(masker(entry.cmd))
+      break
+    default:
+      log(entry)
+  }
+}
+```
 
 ## Polyfills