MCPcopy
hub / github.com/dittofeed/dittofeed / logger

Function logger

packages/backend-lib/src/logger.ts:83–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83export default function logger(): Logger {
84 if (!LOGGER) {
85 let options: PinoConf;
86 let destinationStream: DestinationStream | undefined;
87
88 const { appVersion, logLevel } = config();
89 // Add appVersion to the base options
90 const baseOptions: PinoConf = {
91 level: logLevel,
92 base: {
93 "service.version": appVersion,
94 },
95 };
96
97 if (config().prettyLogs) {
98 options = baseOptions;
99 destinationStream = pinoPretty({
100 translateTime: "HH:MM:ss Z",
101 ignore: "pid,hostname",
102 sync: true,
103 });
104 } else {
105 const { exportLogsHyperDx, hyperDxApiKey } = config();
106
107 options = baseOptions;
108 if (config().googleOps) {
109 Object.assign(options, googleOpsConfig);
110 } else if (exportLogsHyperDx && hyperDxApiKey) {
111 options.mixin = HyperDX.getPinoMixinFunction;
112
113 options.transport = {
114 targets: [
115 {
116 target: "@hyperdx/node-opentelemetry/build/src/otel-logger/pino",
117 options: {
118 apiKey: hyperDxApiKey,
119 service: getServiceName(),
120 },
121 level: logLevel,
122 },
123 ],
124 };
125 }
126 }
127
128 const l = pino(options, destinationStream);
129 LOGGER = l;
130 return l;
131 }
132 return LOGGER;
133}

Callers 15

createCommandsFunction · 0.85
upgradeWorkspaceV010PreFunction · 0.85
upgradeV010PreFunction · 0.85
upgradeWorkspaceV010PostFunction · 0.85
upgradeV010PostFunction · 0.85
upgradeV012PreFunction · 0.85
upgradeV021PreFunction · 0.85
backfillInternalEventsFunction · 0.85

Calls 2

getServiceNameFunction · 0.90
configFunction · 0.70

Tested by

no test coverage detected