export function getModifiedData()

in src/logger.ts [109:136]


export function getModifiedData(
  data: Uint8Array | string,
  encoding?: BufferEncoding,
  stderr = false,
) {
  const currentContext = getCurrentContext();
  if (!currentContext) {
    return data;
  }
  const {isJSON, processedData} = processData(data, encoding);

  let dataWithContext: {
    message: string | Uint8Array;
    'logging.googleapis.com/labels': {execution_id: string | undefined};
    'logging.googleapis.com/spanId': string | undefined;
    severity?: string | undefined;
  };
  if (isJSON) {
    dataWithContext = getJSONWithContext(processedData, currentContext);
    if (stderr && !(SEVERITY in dataWithContext)) {
      dataWithContext[SEVERITY] = 'ERROR';
    }
  } else {
    dataWithContext = getTextWithContext(processedData, currentContext);
  }

  return JSON.stringify(dataWithContext) + '\n';
}