MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/functions-framework-nodejs / getModifiedData

Function getModifiedData

src/logger.ts:109–136  ·  view source on GitHub ↗
(
  data: Uint8Array | string,
  encoding?: BufferEncoding,
  stderr = false,
)

Source from the content-addressed store, hash-verified

107}
108
109export function getModifiedData(
110 data: Uint8Array | string,
111 encoding?: BufferEncoding,
112 stderr = false,
113) {
114 const currentContext = getCurrentContext();
115 if (!currentContext) {
116 return data;
117 }
118 const {isJSON, processedData} = processData(data, encoding);
119
120 let dataWithContext: {
121 message: string | Uint8Array;
122 'logging.googleapis.com/labels': {execution_id: string | undefined};
123 'logging.googleapis.com/spanId': string | undefined;
124 severity?: string | undefined;
125 };
126 if (isJSON) {
127 dataWithContext = getJSONWithContext(processedData, currentContext);
128 if (stderr && !(SEVERITY in dataWithContext)) {
129 dataWithContext[SEVERITY] = 'ERROR';
130 }
131 } else {
132 dataWithContext = getTextWithContext(processedData, currentContext);
133 }
134
135 return JSON.stringify(dataWithContext) + '\n';
136}
137
138function getTextWithContext(
139 data: Uint8Array | string,

Callers 3

logger.tsFile · 0.90
interceptStdoutWriteFunction · 0.85
interceptStderrWriteFunction · 0.85

Calls 4

getCurrentContextFunction · 0.90
processDataFunction · 0.85
getJSONWithContextFunction · 0.85
getTextWithContextFunction · 0.85

Tested by

no test coverage detected