@takeshape/logger 7.134.4 → 10.49.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,305 @@
1
+ import { type logLevels, type logProviders } from './constants.js';
2
+ /**
3
+ * The duration, in fractional milliseconds, that it took to complete this event.
4
+ */
5
+ export type TimeMs = number;
6
+ /**
7
+ * The target host of the HTTP request. This may not be the same as the real hostname of the server.
8
+ */
9
+ export type HttpHost = string;
10
+ /**
11
+ * The HTTP method for the request.
12
+ */
13
+ export type HttpMethod = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
14
+ /**
15
+ * The path of the HTTP request.
16
+ */
17
+ export type HttpPath = string;
18
+ /**
19
+ * The IP address of the computer that issued the request.
20
+ */
21
+ export type HttpRemoteAddr = string;
22
+ /**
23
+ * An ID that uniquely identifies the request and can be used to trace requests.
24
+ */
25
+ export type HttpRequestId = string;
26
+ /**
27
+ * The body of the HTTP request / response.
28
+ */
29
+ export type HttpBody = string;
30
+ /**
31
+ * The value of the Content-Length header representing the size of the request in decimal number of octets.
32
+ */
33
+ export type HttpContentLength = number;
34
+ /**
35
+ * The direction of the HTTP request and response (incoming or outgoing).
36
+ */
37
+ export type HttpDirection = 'incoming' | 'outgoing';
38
+ /**
39
+ * An encoded JSON string representing *all* HTTP headers. This is used for request inspection without the overhead of creating and indexing fields for every header.
40
+ */
41
+ export type HttpHeadersJson = string;
42
+ /**
43
+ * An object representing *select* HTTP headers that need to be searched or graphed.
44
+ */
45
+ export type HttpHeaders = Record<string, any>;
46
+ /**
47
+ * The target port of the HTTP request. This may be different than the port the server is listening on.
48
+ */
49
+ export type HttpPort = number;
50
+ /**
51
+ * The query parameters present on the URL.
52
+ */
53
+ export type HttpQueryString = string;
54
+ /**
55
+ * The HTTP request scheme.
56
+ */
57
+ export type HttpScheme = 'http' | 'https';
58
+ /**
59
+ * A short label / name for the service you are sending the request to, ex: elasticsearch
60
+ */
61
+ export type HttpServiceName = string;
62
+ /**
63
+ * The status as defined by the HTTP status codes.
64
+ */
65
+ export type HttpStatus = number;
66
+ export type LogErrorBacktrace = {
67
+ /**
68
+ * Application name, if applicable. For example, erlang / elixir have multiple apps within the same umbrella project.
69
+ */
70
+ app_name?: string;
71
+ /**
72
+ * The line file path.
73
+ */
74
+ file: string;
75
+ /**
76
+ * The calling function name.
77
+ */
78
+ function: string;
79
+ /**
80
+ * The calling line number.
81
+ */
82
+ line: number;
83
+ };
84
+ export type LogError = {
85
+ /**
86
+ * An optional array of lines, representing the call stack, leading up to the error.
87
+ */
88
+ backtrace?: LogErrorBacktrace[];
89
+ /**
90
+ * Optional message describing the error.
91
+ */
92
+ message?: string;
93
+ /**
94
+ * A JSON encoded string representing additional metadata. This provides insight without the overhead of creating and indexing fields.
95
+ */
96
+ metadata_json?: string;
97
+ /**
98
+ * Required name of the error.
99
+ */
100
+ name: string;
101
+ };
102
+ export type LogContext = {
103
+ /**
104
+ * An open ended object where custom context is supplied.
105
+ */
106
+ custom?: Record<string, Record<string, any>>;
107
+ /**
108
+ * Context about the HTTP request currently being processed (if any)
109
+ */
110
+ http?: {
111
+ host?: HttpHost;
112
+ method: HttpMethod;
113
+ path?: HttpPath;
114
+ remote_addr?: HttpRemoteAddr;
115
+ request_id?: HttpRequestId;
116
+ };
117
+ /**
118
+ * Represents a task or job execution, typically for background tasks or jobs.
119
+ */
120
+ job?: {
121
+ /**
122
+ * The attempt number, if applicable.
123
+ */
124
+ attempt?: number;
125
+ /**
126
+ * A unique identifier for the job or task.
127
+ */
128
+ id?: string;
129
+ /**
130
+ * The name of the queue being processes, if applicable.
131
+ */
132
+ queue_name?: string;
133
+ };
134
+ /**
135
+ * Contextual information about the hosting platform (AWS, Google Cloud, Heroku, etc) the application is hosted.
136
+ */
137
+ platform?: {
138
+ [k: string]: any;
139
+ /**
140
+ * Contextual information about the service running on the Fargate
141
+ */
142
+ fargate?: {
143
+ [k: string]: any;
144
+ /**
145
+ * The unique identifier for the Docker container running inside the Fargate task.
146
+ */
147
+ container_name: string;
148
+ /**
149
+ * The collection of key value pairs found in the Kubernetes Pod metadata field Labels
150
+ */
151
+ labels?: Record<string, any>;
152
+ /**
153
+ * The Fargate service in which this task is running
154
+ */
155
+ service: string;
156
+ /**
157
+ * The task revision in which this container is running.
158
+ */
159
+ task_revision: string;
160
+ /**
161
+ * The task arn in which this container is running.
162
+ */
163
+ task_arn: string;
164
+ };
165
+ /**
166
+ * Contextual information about the Lambda fn
167
+ */
168
+ lambda?: {
169
+ [k: string]: any;
170
+ /**
171
+ * Function name for the Lambda fn.
172
+ */
173
+ function_name: string;
174
+ };
175
+ };
176
+ /**
177
+ * Contextual information on the current release
178
+ */
179
+ release?: {
180
+ /**
181
+ * The git commit sha for the deploy
182
+ */
183
+ commit_hash?: string;
184
+ /**
185
+ * When the release was created, ISO8601 date time.
186
+ */
187
+ created_at?: string;
188
+ /**
189
+ * Deploy version, can be an unique string. Ex: 1.1.2 or a43fdw
190
+ */
191
+ version?: string;
192
+ };
193
+ /**
194
+ * Represents a user in the platform being logged. The interpretation of "user" is left to the consumer.
195
+ */
196
+ user?: {
197
+ /**
198
+ * An email address for the user. This need not be unique to the user. Note that no validation is performed on this field.
199
+ */
200
+ email?: string;
201
+ /**
202
+ * A unique identifier for the user.
203
+ */
204
+ id?: string;
205
+ /**
206
+ * Additional custom metadata you'd like to add to the user.
207
+ */
208
+ meta?: Record<string, any>;
209
+ /**
210
+ * A display name for the user.
211
+ */
212
+ name?: string;
213
+ /**
214
+ * The type of user. Used in systems where there are multiple user types. This helps to denote users in the case of polymorphism.
215
+ */
216
+ type?: string;
217
+ };
218
+ };
219
+ export type LogEvent = {
220
+ /**
221
+ * An open ended object used for custom event data. Only a single root key is allowed, this represents the event type and avoids type collisions in the context of the entire schema.
222
+ */
223
+ custom?: Record<string, Record<string, any>>;
224
+ /**
225
+ * Represents an error or exception.
226
+ */
227
+ error?: LogError;
228
+ /**
229
+ * Represents a HTTP request, both incoming and outgoing. Note the direction field.
230
+ */
231
+ http_request?: {
232
+ body?: HttpBody;
233
+ content_length?: HttpContentLength;
234
+ direction?: HttpDirection;
235
+ headers?: HttpHeaders;
236
+ headers_json?: HttpHeadersJson;
237
+ host?: HttpHost;
238
+ method: HttpMethod;
239
+ path?: HttpPath;
240
+ port?: HttpPort;
241
+ query_string?: HttpQueryString;
242
+ request_id?: HttpRequestId;
243
+ scheme?: HttpScheme;
244
+ service_name?: HttpServiceName;
245
+ };
246
+ /**
247
+ * Represents a HTTP response event, both outgoing and incoming. Note the direction field.
248
+ */
249
+ http_response?: {
250
+ body?: HttpBody;
251
+ content_length?: HttpContentLength;
252
+ direction?: HttpDirection;
253
+ headers?: HttpHeaders;
254
+ headers_json?: HttpHeadersJson;
255
+ request_id?: HttpRequestId;
256
+ service_name?: HttpServiceName;
257
+ status: HttpStatus;
258
+ time_ms?: TimeMs;
259
+ /**
260
+ * The request being responded to. This couples the request data with the response event avoiding the need for joins or external data dependencies. In many cases the data must be coupled with this event because it is represented as a single event (nginx, apache web server, and other reverse proxy servers).
261
+ */
262
+ request?: {
263
+ [k: string]: any;
264
+ host?: HttpHost;
265
+ method?: HttpMethod;
266
+ path?: HttpPath;
267
+ scheme?: HttpScheme;
268
+ };
269
+ };
270
+ };
271
+ export type LogEntry = {
272
+ /**
273
+ * The IOS8601 formatted datetime when the log was generated.
274
+ */
275
+ timestamp?: string | undefined;
276
+ /**
277
+ * The raw log event message, formatting stripped.
278
+ */
279
+ message?: string | undefined;
280
+ /**
281
+ * Contextual metadata about the environment the event takes place in
282
+ */
283
+ context?: LogContext | undefined;
284
+ /**
285
+ * A controlled representation of the event this log line represents.
286
+ */
287
+ event?: LogEvent | undefined;
288
+ };
289
+ export type LogMetadata = {
290
+ error?: Error;
291
+ } & Partial<LogEntry>;
292
+ export type LogFn = typeof console.log;
293
+ export type LoggerFn = (message: string | Error, metadata?: LogMetadata) => void;
294
+ export type Logger = {
295
+ debug: LoggerFn;
296
+ info: LoggerFn;
297
+ warn: LoggerFn;
298
+ error: LoggerFn;
299
+ updateContext: (context: LogContext) => void;
300
+ updateEvent: (event: LogEvent) => void;
301
+ context: LogContext;
302
+ event: LogEvent;
303
+ };
304
+ export type LogLevel = (typeof logLevels)[number];
305
+ export type LogProvider = (typeof logProviders)[number];
package/package.json CHANGED
@@ -1,43 +1,51 @@
1
1
  {
2
2
  "name": "@takeshape/logger",
3
- "version": "7.134.4",
3
+ "version": "10.49.13",
4
4
  "description": "Logging utility.",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "github.com:takeshape/takeshape.git"
9
9
  },
10
- "author": "asprouse",
11
10
  "license": "UNLICENSED",
12
- "engines": {
13
- "node": ">=12"
11
+ "author": "asprouse",
12
+ "exports": {
13
+ "types": "./build/types/index.d.ts",
14
+ "require": "./build/cjs/index.js",
15
+ "import": "./build/esm/index.js",
16
+ "default": "./build/cjs/index.js"
14
17
  },
15
- "main": "lib/index.js",
16
- "module": "es/index.js",
17
- "types": "lib/index.d.ts",
18
+ "main": "./build/cjs/index.js",
19
+ "module": "./build/esm/index.js",
20
+ "types": "./build/types/index.d.ts",
18
21
  "files": [
19
- "lib",
20
- "es"
22
+ "build"
21
23
  ],
22
24
  "scripts": {
23
- "lint": "eslint . --ext .js,.ts",
24
- "lint:code:ci": "eslint . --ext .js,.ts --format junit -o \"${HOME}/test-results/${npm_package_name#*\\/}/eslint-results.xml\"",
25
- "test": "jest",
26
- "test-changed": "pnpm run test -- --changedSince=master",
27
- "test:ci": "JEST_JUNIT_OUTPUT_DIR=\"${HOME}/test-results/${npm_package_name#*\\/}\" JEST_JUNIT_OUTPUT_NAME=jest-results.xml jest --ci --reporters=default --reporters=jest-junit",
28
- "typecheck": "tsc --noEmit",
29
- "clean": "rimraf lib es build *.tsbuildinfo",
30
- "prepublishOnly": "pnpm lint && pnpm test && pnpm clean && pnpm build",
31
- "build": "pnpm clean && pnpm build:types && pnpm build:js && pnpm build:es && pnpm build:copy",
32
- "build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json",
33
- "build:js": "cross-env BABEL_MODULES=commonjs babel src --out-dir lib --extensions \".js,.ts\" --ignore '**/__tests__'",
34
- "build:es": "cross-env BABEL_MODULES=es babel src --out-dir es --extensions \".js,.ts\" --ignore '**/__tests__'",
35
- "build:copy": "cp -rf build/src/* lib/",
36
- "will-it-blend": "pnpm typecheck && pnpm lint -- --quiet && pnpm test -- --silent --coverage false"
25
+ "build": "pnpm build:cjs && pnpm build:esm && pnpm build:types",
26
+ "build:ci": "pnpm clean && pnpm build:cjs && pnpm build:esm && pnpm build:types",
27
+ "build:cjs": "tsc --project tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./build/cjs/package.json",
28
+ "build:esm": "tsc --project tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./build/esm/package.json",
29
+ "build:types": "tsc --project tsconfig.types.json",
30
+ "clean": "del-cli build *.tsbuildinfo",
31
+ "lint": "eslint . --ext .js,.ts,.json",
32
+ "lint:ci": "pnpm lint --quiet --format json -o \"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}/eslint-results.json\"",
33
+ "test": "TZ=UTC vitest run --coverage.enabled --coverage.reporter text-summary",
34
+ "test:ci": "TZ=UTC vitest run --reporter=junit --outputFile=\"${GITHUB_WORKSPACE}/test-results/${npm_package_name#*\\/}/vitest-results.xml\" --coverage.enabled --coverage.reportsDirectory=\"${GITHUB_WORKSPACE}/coverage/${npm_package_name#*\\/}\"",
35
+ "todo": "leasot 'src/**/*.{js,jsx,ts,tsx}'",
36
+ "typecheck": "tsc --noEmit"
37
37
  },
38
38
  "dependencies": {
39
- "@sentry/node": "^5.27.2",
40
- "lodash": "^4.17.20",
41
- "prettyjson": "^1.2.1"
39
+ "lodash": "^4.17.21"
40
+ },
41
+ "devDependencies": {
42
+ "@sentry/types": "^8.30.0",
43
+ "@types/lodash": "^4.14.165"
44
+ },
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
42
50
  }
43
51
  }
package/es/index.js DELETED
@@ -1 +0,0 @@
1
- export { default, loggerWithContext, Logger, TimberMetadata } from './logger';
package/es/logger.js DELETED
@@ -1,97 +0,0 @@
1
- import merge from 'lodash/merge';
2
- import { captureException, setUser, setTag } from '@sentry/node';
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-empty-function
5
- const noop = () => {};
6
-
7
- export function getLogFn(level) {
8
- if (process.env.NODE_ENV === 'test') {
9
- return noop;
10
- }
11
-
12
- if (process.env.IS_OFFLINE) {
13
- const prettyjson = require('prettyjson'); // eslint-disable-line @typescript-eslint/no-var-requires
14
-
15
-
16
- return (message, metadata) => {
17
- console[level](message);
18
-
19
- if (metadata) {
20
- console[level](prettyjson.render(metadata), '\n');
21
- }
22
- };
23
- }
24
-
25
- return (message, metadata) => {
26
- const args = [message];
27
-
28
- if (metadata) {
29
- const {
30
- error,
31
- ...rest
32
- } = metadata;
33
-
34
- if (error) {
35
- captureException(error);
36
- args.push(error);
37
- }
38
-
39
- if (Object.keys(rest).length) {
40
- args.push(JSON.stringify(rest, null, 2));
41
- }
42
- }
43
-
44
- console[level].apply(null, args);
45
- };
46
- }
47
-
48
- function createLogger() {
49
- return {
50
- info: getLogFn('info'),
51
- warn: getLogFn('warn'),
52
- error: getLogFn('error')
53
- };
54
- }
55
-
56
- export default createLogger();
57
-
58
- function setSentryTags(context) {
59
- var _context$custom, _context$custom$proje, _context$user;
60
-
61
- if ((_context$custom = context.custom) !== null && _context$custom !== void 0 && (_context$custom$proje = _context$custom.project) !== null && _context$custom$proje !== void 0 && _context$custom$proje.id) {
62
- var _context$custom2, _context$custom2$proj;
63
-
64
- setTag('projectId', (_context$custom2 = context.custom) === null || _context$custom2 === void 0 ? void 0 : (_context$custom2$proj = _context$custom2.project) === null || _context$custom2$proj === void 0 ? void 0 : _context$custom2$proj.id);
65
- }
66
-
67
- if ((_context$user = context.user) !== null && _context$user !== void 0 && _context$user.id) {
68
- setUser({
69
- id: context.user.id
70
- });
71
- }
72
- }
73
-
74
- export function loggerWithContext(fnContext) {
75
- let context = fnContext;
76
- setSentryTags(context);
77
-
78
- const decorate = logFn => (message, metadata) => {
79
- logFn(message, {
80
- context,
81
- ...metadata
82
- });
83
- };
84
-
85
- return {
86
- info: decorate(getLogFn('info')),
87
- warn: decorate(getLogFn('warn')),
88
- error: decorate(getLogFn('error')),
89
-
90
- updateContext(update) {
91
- setSentryTags(update);
92
- context = merge(context, update);
93
- },
94
-
95
- context
96
- };
97
- }
package/es/types.js DELETED
File without changes
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default, loggerWithContext, Logger, TimberMetadata } from './logger';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC"}
package/lib/index.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _logger.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "loggerWithContext", {
13
- enumerable: true,
14
- get: function () {
15
- return _logger.loggerWithContext;
16
- }
17
- });
18
- Object.defineProperty(exports, "Logger", {
19
- enumerable: true,
20
- get: function () {
21
- return _logger.Logger;
22
- }
23
- });
24
- Object.defineProperty(exports, "TimberMetadata", {
25
- enumerable: true,
26
- get: function () {
27
- return _logger.TimberMetadata;
28
- }
29
- });
30
-
31
- var _logger = _interopRequireWildcard(require("./logger"));
32
-
33
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
34
-
35
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
package/lib/logger.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { TimberContext, TimberLogEntry } from './types';
2
- export interface TimberMetadata extends Partial<TimberLogEntry> {
3
- error?: Error;
4
- }
5
- export declare type LogFn = (message: string, metadata?: TimberMetadata) => void;
6
- export interface Logger {
7
- info: LogFn;
8
- error: LogFn;
9
- warn: LogFn;
10
- updateContext: (context: TimberContext) => void;
11
- context: TimberContext;
12
- }
13
- export declare function getLogFn(level: 'info' | 'warn' | 'error'): LogFn;
14
- declare const _default: Record<string, LogFn>;
15
- export default _default;
16
- export declare function loggerWithContext(fnContext: TimberContext): Logger;
17
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAGtD,MAAM,WAAW,cAAe,SAAQ,OAAO,CAAC,cAAc,CAAC;IAC7D,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AACD,oBAAY,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;AAEzE,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD,OAAO,EAAE,aAAa,CAAC;CACxB;AAKD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CA+BhE;;AAUD,wBAA8B;AAW9B,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAkBlE"}
package/lib/logger.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getLogFn = getLogFn;
7
- exports.loggerWithContext = loggerWithContext;
8
- exports.default = void 0;
9
-
10
- var _merge = _interopRequireDefault(require("lodash/merge"));
11
-
12
- var _node = require("@sentry/node");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- // eslint-disable-next-line @typescript-eslint/no-empty-function
17
- const noop = () => {};
18
-
19
- function getLogFn(level) {
20
- if (process.env.NODE_ENV === 'test') {
21
- return noop;
22
- }
23
-
24
- if (process.env.IS_OFFLINE) {
25
- const prettyjson = require('prettyjson'); // eslint-disable-line @typescript-eslint/no-var-requires
26
-
27
-
28
- return (message, metadata) => {
29
- console[level](message);
30
-
31
- if (metadata) {
32
- console[level](prettyjson.render(metadata), '\n');
33
- }
34
- };
35
- }
36
-
37
- return (message, metadata) => {
38
- const args = [message];
39
-
40
- if (metadata) {
41
- const {
42
- error,
43
- ...rest
44
- } = metadata;
45
-
46
- if (error) {
47
- (0, _node.captureException)(error);
48
- args.push(error);
49
- }
50
-
51
- if (Object.keys(rest).length) {
52
- args.push(JSON.stringify(rest, null, 2));
53
- }
54
- }
55
-
56
- console[level].apply(null, args);
57
- };
58
- }
59
-
60
- function createLogger() {
61
- return {
62
- info: getLogFn('info'),
63
- warn: getLogFn('warn'),
64
- error: getLogFn('error')
65
- };
66
- }
67
-
68
- var _default = createLogger();
69
-
70
- exports.default = _default;
71
-
72
- function setSentryTags(context) {
73
- var _context$custom, _context$custom$proje, _context$user;
74
-
75
- if ((_context$custom = context.custom) !== null && _context$custom !== void 0 && (_context$custom$proje = _context$custom.project) !== null && _context$custom$proje !== void 0 && _context$custom$proje.id) {
76
- var _context$custom2, _context$custom2$proj;
77
-
78
- (0, _node.setTag)('projectId', (_context$custom2 = context.custom) === null || _context$custom2 === void 0 ? void 0 : (_context$custom2$proj = _context$custom2.project) === null || _context$custom2$proj === void 0 ? void 0 : _context$custom2$proj.id);
79
- }
80
-
81
- if ((_context$user = context.user) !== null && _context$user !== void 0 && _context$user.id) {
82
- (0, _node.setUser)({
83
- id: context.user.id
84
- });
85
- }
86
- }
87
-
88
- function loggerWithContext(fnContext) {
89
- let context = fnContext;
90
- setSentryTags(context);
91
-
92
- const decorate = logFn => (message, metadata) => {
93
- logFn(message, {
94
- context,
95
- ...metadata
96
- });
97
- };
98
-
99
- return {
100
- info: decorate(getLogFn('info')),
101
- warn: decorate(getLogFn('warn')),
102
- error: decorate(getLogFn('error')),
103
-
104
- updateContext(update) {
105
- setSentryTags(update);
106
- context = (0, _merge.default)(context, update);
107
- },
108
-
109
- context
110
- };
111
- }