MCPcopy Create free account
hub / github.com/FormidableLabs/pino-lambda / write

Function write

src/destination.ts:16–40  ·  view source on GitHub ↗
(chunk, encoding, callback)

Source from the content-addressed store, hash-verified

14 const writeable = new Writable({
15 defaultEncoding: 'utf8',
16 write(chunk, encoding, callback) {
17 const storageProvider = options.storageProvider || GlobalContextStorageProvider;
18 const formatter = options.formatter || new CloudwatchLogFormatter();
19
20 const data = JSON.parse(chunk);
21 const lambdaContext = storageProvider.getContext() || {};
22
23 // format the combined request context and log data
24 let output = formatter.format({ ...lambdaContext, ...data });
25
26 // replace characters for proper formatting
27 output = output.replace(/\n/, '\r');
28
29 // final entry must end with carriage return
30 output += '\n';
31
32 /* istanbul ignore else */
33 if (options.streamWriter) {
34 options.streamWriter(output);
35 } else {
36 process.stdout.write(output);
37 }
38
39 callback();
40 },
41 });
42
43 return writeable;

Callers

nothing calls this directly

Calls 1

formatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…