sdk-logs 0.7.0 → 0.8.0
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.
- package/dist/domain.objects/LogOutlet.d.ts +33 -0
- package/dist/domain.objects/LogOutlet.js +3 -0
- package/dist/domain.objects/LogOutlet.js.map +1 -0
- package/dist/domain.operations/asCurrentIsoTimestamp.d.ts +5 -0
- package/dist/domain.operations/asCurrentIsoTimestamp.js +12 -0
- package/dist/domain.operations/asCurrentIsoTimestamp.js.map +1 -0
- package/dist/domain.operations/genLogMethods.d.ts +7 -2
- package/dist/domain.operations/genLogMethods.js +25 -6
- package/dist/domain.operations/genLogMethods.js.map +1 -1
- package/dist/domain.operations/generateLogMethod.d.ts +3 -1
- package/dist/domain.operations/generateLogMethod.js +32 -16
- package/dist/domain.operations/generateLogMethod.js.map +1 -1
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchBatches.d.ts +8 -0
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchBatches.js +47 -0
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchBatches.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchLogEvents.d.ts +9 -0
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchLogEvents.js +15 -0
- package/dist/domain.operations/outlets/cloudwatch/asCloudWatchLogEvents.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/asDefaultLogStreamName.d.ts +6 -0
- package/dist/domain.operations/outlets/cloudwatch/asDefaultLogStreamName.js +24 -0
- package/dist/domain.operations/outlets/cloudwatch/asDefaultLogStreamName.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName.d.ts +18 -0
- package/dist/domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName.js +57 -0
- package/dist/domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.d.ts +8 -0
- package/dist/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.js +46 -0
- package/dist/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/computeLogEventSize.d.ts +8 -0
- package/dist/domain.operations/outlets/cloudwatch/computeLogEventSize.js +15 -0
- package/dist/domain.operations/outlets/cloudwatch/computeLogEventSize.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/drainBuffer.d.ts +6 -0
- package/dist/domain.operations/outlets/cloudwatch/drainBuffer.js +12 -0
- package/dist/domain.operations/outlets/cloudwatch/drainBuffer.js.map +1 -0
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.d.ts +24 -0
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.js +205 -0
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { LogLevel } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* .what = a log event that flows through outlets
|
|
4
|
+
* .why = standardized shape for log data across destinations
|
|
5
|
+
*/
|
|
6
|
+
export interface LogEvent {
|
|
7
|
+
level: LogLevel;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
message: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* .what = an outlet that receives log events
|
|
14
|
+
* .why = enables logs to route to external destinations (e.g., CloudWatch)
|
|
15
|
+
*/
|
|
16
|
+
export interface LogOutlet {
|
|
17
|
+
/**
|
|
18
|
+
* .what = send a log event to this outlet
|
|
19
|
+
* .why = buffers or dispatches the event to the destination
|
|
20
|
+
*/
|
|
21
|
+
send: (event: LogEvent) => void;
|
|
22
|
+
/**
|
|
23
|
+
* .what = flush buffered events to the destination
|
|
24
|
+
* .why = ensures all buffered logs are sent before process exit
|
|
25
|
+
*/
|
|
26
|
+
flush: () => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* .what = close the outlet and release resources
|
|
29
|
+
* .why = cleans up timers and process listeners to prevent leaks in tests
|
|
30
|
+
* .note = optional - not all outlets require cleanup
|
|
31
|
+
*/
|
|
32
|
+
close?: () => void;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogOutlet.js","sourceRoot":"","sources":["../../src/domain.objects/LogOutlet.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asCurrentIsoTimestamp = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = returns current UTC timestamp in ISO 8601 format
|
|
6
|
+
* .why = extracts decode-friction from orchestrators
|
|
7
|
+
*/
|
|
8
|
+
const asCurrentIsoTimestamp = () => {
|
|
9
|
+
return new Date().toISOString();
|
|
10
|
+
};
|
|
11
|
+
exports.asCurrentIsoTimestamp = asCurrentIsoTimestamp;
|
|
12
|
+
//# sourceMappingURL=asCurrentIsoTimestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asCurrentIsoTimestamp.js","sourceRoot":"","sources":["../../src/domain.operations/asCurrentIsoTimestamp.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,qBAAqB,GAAG,GAAW,EAAE;IAChD,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LogLevel } from '../domain.objects/constants';
|
|
2
|
+
import type { LogOutlet } from '../domain.objects/LogOutlet';
|
|
2
3
|
import { type LogMethod } from './generateLogMethod';
|
|
3
4
|
export interface LogMethods {
|
|
4
5
|
/**
|
|
@@ -36,7 +37,11 @@ export interface LogMethods {
|
|
|
36
37
|
* define how to generate the log methods
|
|
37
38
|
* - allows you to specify the minimal log level to use for your application
|
|
38
39
|
* - defaults to recommended levels for the environment
|
|
40
|
+
* - allows you to specify outlets for log events to flow to external destinations
|
|
39
41
|
*/
|
|
40
|
-
export declare const genLogMethods: ({
|
|
41
|
-
|
|
42
|
+
export declare const genLogMethods: ({ level, outlets, }?: {
|
|
43
|
+
level?: {
|
|
44
|
+
minimum?: LogLevel;
|
|
45
|
+
};
|
|
46
|
+
outlets?: LogOutlet[];
|
|
42
47
|
}) => LogMethods;
|
|
@@ -8,15 +8,34 @@ const getRecommendedMinimalLogLevelForEnvironment_1 = require("./getRecommendedM
|
|
|
8
8
|
* define how to generate the log methods
|
|
9
9
|
* - allows you to specify the minimal log level to use for your application
|
|
10
10
|
* - defaults to recommended levels for the environment
|
|
11
|
+
* - allows you to specify outlets for log events to flow to external destinations
|
|
11
12
|
*/
|
|
12
|
-
const genLogMethods = ({
|
|
13
|
+
const genLogMethods = ({ level, outlets, } = {}) => {
|
|
14
|
+
// derive minimal log level
|
|
15
|
+
const derivedMinimalLogLevel = level?.minimum ?? (0, getRecommendedMinimalLogLevelForEnvironment_1.getRecommendedMinimalLogLevelForEnvironment)();
|
|
13
16
|
// generate the methods
|
|
14
17
|
return {
|
|
15
|
-
error: (0, generateLogMethod_1.generateLogMethod)({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
error: (0, generateLogMethod_1.generateLogMethod)({
|
|
19
|
+
level: constants_1.LogLevel.ERROR,
|
|
20
|
+
minimalLogLevel: derivedMinimalLogLevel,
|
|
21
|
+
outlets,
|
|
22
|
+
}),
|
|
23
|
+
warn: (0, generateLogMethod_1.generateLogMethod)({
|
|
24
|
+
level: constants_1.LogLevel.WARN,
|
|
25
|
+
minimalLogLevel: derivedMinimalLogLevel,
|
|
26
|
+
outlets,
|
|
27
|
+
}),
|
|
28
|
+
info: (0, generateLogMethod_1.generateLogMethod)({
|
|
29
|
+
level: constants_1.LogLevel.INFO,
|
|
30
|
+
minimalLogLevel: derivedMinimalLogLevel,
|
|
31
|
+
outlets,
|
|
32
|
+
}),
|
|
33
|
+
debug: (0, generateLogMethod_1.generateLogMethod)({
|
|
34
|
+
level: constants_1.LogLevel.DEBUG,
|
|
35
|
+
minimalLogLevel: derivedMinimalLogLevel,
|
|
36
|
+
outlets,
|
|
37
|
+
}),
|
|
38
|
+
_: Object.freeze({ level: derivedMinimalLogLevel }),
|
|
20
39
|
};
|
|
21
40
|
};
|
|
22
41
|
exports.genLogMethods = genLogMethods;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/genLogMethods.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"genLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/genLogMethods.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAGzD,2DAAwE;AACxE,+GAA4G;AAqC5G;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,KAAK,EACL,OAAO,MAIL,EAAE,EAAc,EAAE;IACpB,2BAA2B;IAC3B,MAAM,sBAAsB,GAC1B,KAAK,EAAE,OAAO,IAAI,IAAA,yFAA2C,GAAE,CAAC;IAElE,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe,EAAE,sBAAsB;YACvC,OAAO;SACR,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe,EAAE,sBAAsB;YACvC,OAAO;SACR,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe,EAAE,sBAAsB;YACvC,OAAO;SACR,CAAC;QACF,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe,EAAE,sBAAsB;YACvC,OAAO;SACR,CAAC;QACF,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC,CAAC;AAnCW,QAAA,aAAa,iBAmCxB"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { LogLevel } from '../domain.objects/constants';
|
|
2
|
+
import type { LogOutlet } from '../domain.objects/LogOutlet';
|
|
2
3
|
import type { LogTrail } from '../domain.objects/LogTrail';
|
|
3
4
|
export type LogMethod = (message: string, metadata?: any) => void;
|
|
4
|
-
export declare const generateLogMethod: ({ level, minimalLogLevel, trail, env, }: {
|
|
5
|
+
export declare const generateLogMethod: ({ level, minimalLogLevel, trail, env, outlets, }: {
|
|
5
6
|
level: LogLevel;
|
|
6
7
|
minimalLogLevel: LogLevel;
|
|
7
8
|
trail?: LogTrail;
|
|
8
9
|
env?: {
|
|
9
10
|
commit: string;
|
|
10
11
|
};
|
|
12
|
+
outlets?: LogOutlet[];
|
|
11
13
|
}) => (message: string, metadata?: object) => void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateLogMethod = void 0;
|
|
4
4
|
const constants_1 = require("../domain.objects/constants");
|
|
5
|
+
const asCurrentIsoTimestamp_1 = require("./asCurrentIsoTimestamp");
|
|
5
6
|
const formatLogContentsForEnvironment_1 = require("./formatLogContentsForEnvironment");
|
|
6
7
|
/*
|
|
7
8
|
define priority order of log levels and make it easy to ask questions about
|
|
@@ -13,25 +14,40 @@ const logLevelPriorityOrder = [
|
|
|
13
14
|
constants_1.LogLevel.DEBUG,
|
|
14
15
|
];
|
|
15
16
|
const aIsEqualOrMoreImportantThanB = ({ a, b }) => logLevelPriorityOrder.indexOf(a) - logLevelPriorityOrder.indexOf(b) <= 0;
|
|
16
|
-
const generateLogMethod = ({ level, minimalLogLevel, trail, env, }) => {
|
|
17
|
+
const generateLogMethod = ({ level, minimalLogLevel, trail, env, outlets, }) => {
|
|
17
18
|
return (message, metadata) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
// check level threshold
|
|
20
|
+
if (!aIsEqualOrMoreImportantThanB({ a: level, b: minimalLogLevel }))
|
|
21
|
+
return;
|
|
22
|
+
// create timestamp once for consistency
|
|
23
|
+
const timestamp = (0, asCurrentIsoTimestamp_1.asCurrentIsoTimestamp)();
|
|
24
|
+
// determine the console level (i.e., use warn if we can to make the logs stand out more)
|
|
25
|
+
const consoleMethod = aIsEqualOrMoreImportantThanB({
|
|
26
|
+
a: level,
|
|
27
|
+
b: constants_1.LogLevel.WARN,
|
|
28
|
+
})
|
|
29
|
+
? console.warn
|
|
30
|
+
: console.log; // tslint:disable-line no-console
|
|
31
|
+
// output the message to console, which will get picked up by cloudwatch when deployed lambda is invoked
|
|
32
|
+
consoleMethod((0, formatLogContentsForEnvironment_1.formatLogContentsForEnvironment)({
|
|
33
|
+
level,
|
|
34
|
+
timestamp,
|
|
35
|
+
message,
|
|
36
|
+
metadata,
|
|
37
|
+
trail,
|
|
38
|
+
env,
|
|
39
|
+
}));
|
|
40
|
+
// dispatch to outlets (fail-fast: errors propagate to caller)
|
|
41
|
+
if (outlets && outlets.length > 0) {
|
|
42
|
+
const event = {
|
|
28
43
|
level,
|
|
29
|
-
timestamp
|
|
44
|
+
timestamp,
|
|
30
45
|
message,
|
|
31
|
-
metadata,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
metadata: metadata,
|
|
47
|
+
};
|
|
48
|
+
for (const outlet of outlets) {
|
|
49
|
+
outlet.send(event);
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
};
|
|
37
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAIzD,mEAAgE;AAChE,uFAAoF;AAEpF;;EAEE;AACF,MAAM,qBAAqB,GAAG;IAC5B,oBAAQ,CAAC,KAAK;IACd,oBAAQ,CAAC,IAAI;IACb,oBAAQ,CAAC,IAAI;IACb,oBAAQ,CAAC,KAAK;CACf,CAAC;AACF,MAAM,4BAA4B,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAgC,EAAE,EAAE,CAC9E,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAUpE,MAAM,iBAAiB,GAAG,CAAC,EAChC,KAAK,EACL,eAAe,EACf,KAAK,EACL,GAAG,EACH,OAAO,GAOR,EAAE,EAAE;IACH,OAAO,CAAC,OAAe,EAAE,QAAiB,EAAE,EAAE;QAC5C,wBAAwB;QACxB,IAAI,CAAC,4BAA4B,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC;YAAE,OAAO;QAE5E,wCAAwC;QACxC,MAAM,SAAS,GAAG,IAAA,6CAAqB,GAAE,CAAC;QAE1C,yFAAyF;QACzF,MAAM,aAAa,GAAG,4BAA4B,CAAC;YACjD,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,oBAAQ,CAAC,IAAI;SACjB,CAAC;YACA,CAAC,CAAC,OAAO,CAAC,IAAI;YACd,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,iCAAiC;QAElD,wGAAwG;QACxG,aAAa,CACX,IAAA,iEAA+B,EAAC;YAC9B,KAAK;YACL,SAAS;YACT,OAAO;YACP,QAAQ;YACR,KAAK;YACL,GAAG;SACJ,CAAC,CACH,CAAC;QAEF,8DAA8D;QAC9D,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,KAAK,GAAa;gBACtB,KAAK;gBACL,SAAS;gBACT,OAAO;gBACP,QAAQ,EAAE,QAA+C;aAC1D,CAAC;YACF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AArDW,QAAA,iBAAiB,qBAqD5B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LogEvent } from '../../../domain.objects/LogOutlet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = splits log events into CloudWatch-compliant batches
|
|
4
|
+
* .why = CloudWatch rejects batches over 1MB or 10k events
|
|
5
|
+
*
|
|
6
|
+
* @returns array of batches, each within CloudWatch limits
|
|
7
|
+
*/
|
|
8
|
+
export declare const asCloudWatchBatches: (events: LogEvent[]) => LogEvent[][];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asCloudWatchBatches = void 0;
|
|
4
|
+
const computeLogEventSize_1 = require("./computeLogEventSize");
|
|
5
|
+
/**
|
|
6
|
+
* .what = CloudWatch PutLogEvents limits
|
|
7
|
+
* .why = CloudWatch rejects batches that exceed these limits
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
|
|
10
|
+
*/
|
|
11
|
+
const CLOUDWATCH_MAX_BATCH_SIZE = 1048576; // 1MB
|
|
12
|
+
const CLOUDWATCH_MAX_BATCH_COUNT = 10000;
|
|
13
|
+
const CLOUDWATCH_EVENT_OVERHEAD = 26; // bytes per event
|
|
14
|
+
/**
|
|
15
|
+
* .what = splits log events into CloudWatch-compliant batches
|
|
16
|
+
* .why = CloudWatch rejects batches over 1MB or 10k events
|
|
17
|
+
*
|
|
18
|
+
* @returns array of batches, each within CloudWatch limits
|
|
19
|
+
*/
|
|
20
|
+
const asCloudWatchBatches = (events) => {
|
|
21
|
+
if (events.length === 0)
|
|
22
|
+
return [];
|
|
23
|
+
const batches = [];
|
|
24
|
+
let currentBatch = [];
|
|
25
|
+
let currentBatchSize = 0;
|
|
26
|
+
for (const event of events) {
|
|
27
|
+
const eventSize = (0, computeLogEventSize_1.computeLogEventSize)(event) + CLOUDWATCH_EVENT_OVERHEAD;
|
|
28
|
+
// check if event would exceed batch limits
|
|
29
|
+
const wouldExceedSize = currentBatchSize + eventSize > CLOUDWATCH_MAX_BATCH_SIZE;
|
|
30
|
+
const wouldExceedCount = currentBatch.length >= CLOUDWATCH_MAX_BATCH_COUNT;
|
|
31
|
+
// start new batch if limits exceeded
|
|
32
|
+
if (currentBatch.length > 0 && (wouldExceedSize || wouldExceedCount)) {
|
|
33
|
+
batches.push(currentBatch);
|
|
34
|
+
currentBatch = [];
|
|
35
|
+
currentBatchSize = 0;
|
|
36
|
+
}
|
|
37
|
+
currentBatch.push(event);
|
|
38
|
+
currentBatchSize += eventSize;
|
|
39
|
+
}
|
|
40
|
+
// push final batch if non-empty
|
|
41
|
+
if (currentBatch.length > 0) {
|
|
42
|
+
batches.push(currentBatch);
|
|
43
|
+
}
|
|
44
|
+
return batches;
|
|
45
|
+
};
|
|
46
|
+
exports.asCloudWatchBatches = asCloudWatchBatches;
|
|
47
|
+
//# sourceMappingURL=asCloudWatchBatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asCloudWatchBatches.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/asCloudWatchBatches.ts"],"names":[],"mapp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|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LogEvent } from '../../../domain.objects/LogOutlet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = transforms LogEvents to CloudWatch PutLogEvents format
|
|
4
|
+
* .why = extracts decode-friction from orchestrator
|
|
5
|
+
*/
|
|
6
|
+
export declare const asCloudWatchLogEvents: (events: LogEvent[]) => Array<{
|
|
7
|
+
timestamp: number;
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asCloudWatchLogEvents = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = transforms LogEvents to CloudWatch PutLogEvents format
|
|
6
|
+
* .why = extracts decode-friction from orchestrator
|
|
7
|
+
*/
|
|
8
|
+
const asCloudWatchLogEvents = (events) => {
|
|
9
|
+
return events.map((e) => ({
|
|
10
|
+
timestamp: Date.parse(e.timestamp),
|
|
11
|
+
message: JSON.stringify(e),
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
exports.asCloudWatchLogEvents = asCloudWatchLogEvents;
|
|
15
|
+
//# sourceMappingURL=asCloudWatchLogEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asCloudWatchLogEvents.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/asCloudWatchLogEvents.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CACnC,MAAkB,EAC6B,EAAE;IACjD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAClC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3B,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = generates a default log stream name for CloudWatch
|
|
3
|
+
* .why = matches Lambda's log stream format: YYYY/MM/DD/[$LATEST]instance-id
|
|
4
|
+
* .note = explicit opt-in: user adds outlet only when automatic forwarder absent
|
|
5
|
+
*/
|
|
6
|
+
export declare const asDefaultLogStreamName: () => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asDefaultLogStreamName = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
/**
|
|
6
|
+
* .what = extracts date in Lambda log stream format (YYYY/MM/DD)
|
|
7
|
+
* .why = matches Lambda's native log stream date format
|
|
8
|
+
*/
|
|
9
|
+
const asLambdaDatePrefix = (input) => {
|
|
10
|
+
const iso = input.from.toISOString().split('T')[0];
|
|
11
|
+
return iso.replace(/-/g, '/'); // YYYY-MM-DD -> YYYY/MM/DD
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* .what = generates a default log stream name for CloudWatch
|
|
15
|
+
* .why = matches Lambda's log stream format: YYYY/MM/DD/[$LATEST]instance-id
|
|
16
|
+
* .note = explicit opt-in: user adds outlet only when automatic forwarder absent
|
|
17
|
+
*/
|
|
18
|
+
const asDefaultLogStreamName = () => {
|
|
19
|
+
const datePrefix = asLambdaDatePrefix({ from: new Date() });
|
|
20
|
+
const instanceId = (0, crypto_1.randomUUID)();
|
|
21
|
+
return `${datePrefix}/[$LATEST]${instanceId}`;
|
|
22
|
+
};
|
|
23
|
+
exports.asDefaultLogStreamName = asDefaultLogStreamName;
|
|
24
|
+
//# sourceMappingURL=asDefaultLogStreamName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asDefaultLogStreamName.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/asDefaultLogStreamName.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;IACpD,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,2BAA2B;AAC5D,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,GAAW,EAAE;IACjD,MAAM,UAAU,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAA,mBAAU,GAAE,CAAC;IAChC,OAAO,GAAG,UAAU,aAAa,UAAU,EAAE,CAAC;AAChD,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = generates a lambda-style log group name
|
|
3
|
+
* .why = CloudWatch log groups follow `/aws/lambda/{service}-{env}` pattern
|
|
4
|
+
*
|
|
5
|
+
* .note = performs I/O when service is not provided:
|
|
6
|
+
* - reads package.json from cwd for service name
|
|
7
|
+
* - reads env vars (ENVIRONMENT_ACCESS, ENV_ACCESS, STAGE, NODE_ENV) for env.access
|
|
8
|
+
* for pure usage, pass both service and env.access explicitly.
|
|
9
|
+
*
|
|
10
|
+
* @param service - service name (default: reads from package.json)
|
|
11
|
+
* @param env.access - environment access level (default: from env vars, fallback 'local')
|
|
12
|
+
*/
|
|
13
|
+
export declare const asLambdaStyleLogGroupName: ({ service, env, }?: {
|
|
14
|
+
service?: string;
|
|
15
|
+
env?: {
|
|
16
|
+
access?: string;
|
|
17
|
+
};
|
|
18
|
+
}) => string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asLambdaStyleLogGroupName = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* .what = generates a lambda-style log group name
|
|
8
|
+
* .why = CloudWatch log groups follow `/aws/lambda/{service}-{env}` pattern
|
|
9
|
+
*
|
|
10
|
+
* .note = performs I/O when service is not provided:
|
|
11
|
+
* - reads package.json from cwd for service name
|
|
12
|
+
* - reads env vars (ENVIRONMENT_ACCESS, ENV_ACCESS, STAGE, NODE_ENV) for env.access
|
|
13
|
+
* for pure usage, pass both service and env.access explicitly.
|
|
14
|
+
*
|
|
15
|
+
* @param service - service name (default: reads from package.json)
|
|
16
|
+
* @param env.access - environment access level (default: from env vars, fallback 'local')
|
|
17
|
+
*/
|
|
18
|
+
const asLambdaStyleLogGroupName = ({ service, env, } = {}) => {
|
|
19
|
+
const serviceName = service ?? getPackageJsonName();
|
|
20
|
+
const envAccess = env?.access ?? getEnvironmentAccessFromEnvVar();
|
|
21
|
+
return `/aws/lambda/${serviceName}-${envAccess}`;
|
|
22
|
+
};
|
|
23
|
+
exports.asLambdaStyleLogGroupName = asLambdaStyleLogGroupName;
|
|
24
|
+
/**
|
|
25
|
+
* .what = reads package name from package.json in cwd
|
|
26
|
+
* .why = service name defaults to package name for consistency
|
|
27
|
+
*/
|
|
28
|
+
const getPackageJsonName = () => {
|
|
29
|
+
try {
|
|
30
|
+
const pkgPath = (0, path_1.join)(process.cwd(), 'package.json');
|
|
31
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
|
|
32
|
+
return pkg.name ?? 'unknown-service';
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
// allowlist: file not found or parse errors are expected in some environments
|
|
36
|
+
if (error instanceof Error &&
|
|
37
|
+
(error.message.includes('ENOENT') ||
|
|
38
|
+
error.message.includes('Unexpected token') ||
|
|
39
|
+
error.message.includes('JSON'))) {
|
|
40
|
+
return 'unknown-service';
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* .what = reads environment access from env var
|
|
47
|
+
* .why = enables environment-specific log groups (test, prep, prod)
|
|
48
|
+
*/
|
|
49
|
+
const getEnvironmentAccessFromEnvVar = () => {
|
|
50
|
+
// check common env var patterns
|
|
51
|
+
return (process.env.ENVIRONMENT_ACCESS ??
|
|
52
|
+
process.env.ENV_ACCESS ??
|
|
53
|
+
process.env.STAGE ??
|
|
54
|
+
process.env.NODE_ENV ??
|
|
55
|
+
'local');
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=asLambdaStyleLogGroupName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaStyleLogGroupName.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAE5B;;;;;;;;;;;GAWG;AACI,MAAM,yBAAyB,GAAG,CAAC,EACxC,OAAO,EACP,GAAG,MAID,EAAE,EAAU,EAAE;IAChB,MAAM,WAAW,GAAG,OAAO,IAAI,kBAAkB,EAAE,CAAC;IACpD,MAAM,SAAS,GAAG,GAAG,EAAE,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAClE,OAAO,eAAe,WAAW,IAAI,SAAS,EAAE,CAAC;AACnD,CAAC,CAAC;AAVW,QAAA,yBAAyB,6BAUpC;AAEF;;;GAGG;AACH,MAAM,kBAAkB,GAAG,GAAW,EAAE;IACtC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC,IAAI,IAAI,iBAAiB,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,8EAA8E;QAC9E,IACE,KAAK,YAAY,KAAK;YACtB,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAC/B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBAC1C,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACjC,CAAC;YACD,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,8BAA8B,GAAG,GAAW,EAAE;IAClD,gCAAgC;IAChC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAC9B,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,OAAO,CAAC,GAAG,CAAC,KAAK;QACjB,OAAO,CAAC,GAAG,CAAC,QAAQ;QACpB,OAAO,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = validates AWS credentials are available via common sources
|
|
3
|
+
* .why = fail-fast at outlet creation rather than on first flush
|
|
4
|
+
*
|
|
5
|
+
* .note = checks env vars and shared credentials file.
|
|
6
|
+
* async credential providers (SSO, IAM roles) are validated on first flush.
|
|
7
|
+
*/
|
|
8
|
+
export declare const assertAwsCredentialsPresent: () => void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertAwsCredentialsPresent = void 0;
|
|
4
|
+
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
+
/**
|
|
6
|
+
* .what = validates AWS credentials are available via common sources
|
|
7
|
+
* .why = fail-fast at outlet creation rather than on first flush
|
|
8
|
+
*
|
|
9
|
+
* .note = checks env vars and shared credentials file.
|
|
10
|
+
* async credential providers (SSO, IAM roles) are validated on first flush.
|
|
11
|
+
*/
|
|
12
|
+
const assertAwsCredentialsPresent = () => {
|
|
13
|
+
// check env var credentials (most common in non-Lambda environments)
|
|
14
|
+
const hasEnvCredentials = process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY;
|
|
15
|
+
// check if profile is specified (indicates shared credentials or SSO)
|
|
16
|
+
const hasProfile = process.env.AWS_PROFILE;
|
|
17
|
+
// check if role ARN is specified (indicates assume-role config)
|
|
18
|
+
const hasRoleArn = process.env.AWS_ROLE_ARN;
|
|
19
|
+
// check if web identity is configured (EKS/IRSA)
|
|
20
|
+
const hasWebIdentity = process.env.AWS_WEB_IDENTITY_TOKEN_FILE && process.env.AWS_ROLE_ARN;
|
|
21
|
+
// check if container credentials are configured (ECS/Fargate)
|
|
22
|
+
const hasContainerCredentials = process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI ||
|
|
23
|
+
process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI;
|
|
24
|
+
// check if in EC2/Lambda (metadata service provides credentials)
|
|
25
|
+
const hasMetadataService = process.env.AWS_EXECUTION_ENV;
|
|
26
|
+
// if none of the common credential sources are present, fail fast
|
|
27
|
+
if (!hasEnvCredentials &&
|
|
28
|
+
!hasProfile &&
|
|
29
|
+
!hasRoleArn &&
|
|
30
|
+
!hasWebIdentity &&
|
|
31
|
+
!hasContainerCredentials &&
|
|
32
|
+
!hasMetadataService) {
|
|
33
|
+
throw new error_fns_1.BadRequestError('AWS credentials not configured. genCloudwatchOutlet requires valid AWS credentials.', {
|
|
34
|
+
hint: [
|
|
35
|
+
'configure credentials via one of:',
|
|
36
|
+
' - env: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY',
|
|
37
|
+
' - env: AWS_PROFILE (for shared credentials or SSO)',
|
|
38
|
+
' - env: AWS_WEB_IDENTITY_TOKEN_FILE + AWS_ROLE_ARN (for EKS/IRSA)',
|
|
39
|
+
' - container: execute in ECS/Fargate with task role',
|
|
40
|
+
' - metadata: execute in EC2/Lambda with instance/execution role',
|
|
41
|
+
].join('\n'),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.assertAwsCredentialsPresent = assertAwsCredentialsPresent;
|
|
46
|
+
//# sourceMappingURL=assertAwsCredentialsPresent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertAwsCredentialsPresent.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.ts"],"names":[],"mappings":";;;AAAA,mDAAsD;AAEtD;;;;;;GAMG;AACI,MAAM,2BAA2B,GAAG,GAAS,EAAE;IACpD,qEAAqE;IACrE,MAAM,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAErE,sEAAsE;IACtE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAE3C,gEAAgE;IAChE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAE5C,iDAAiD;IACjD,MAAM,cAAc,GAClB,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAEtE,8DAA8D;IAC9D,MAAM,uBAAuB,GAC3B,OAAO,CAAC,GAAG,CAAC,sCAAsC;QAClD,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC;IAEjD,iEAAiE;IACjE,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAEzD,kEAAkE;IAClE,IACE,CAAC,iBAAiB;QAClB,CAAC,UAAU;QACX,CAAC,UAAU;QACX,CAAC,cAAc;QACf,CAAC,uBAAuB;QACxB,CAAC,kBAAkB,EACnB,CAAC;QACD,MAAM,IAAI,2BAAe,CACvB,qFAAqF,EACrF;YACE,IAAI,EAAE;gBACJ,mCAAmC;gBACnC,oDAAoD;gBACpD,sDAAsD;gBACtD,oEAAoE;gBACpE,sDAAsD;gBACtD,kEAAkE;aACnE,CAAC,IAAI,CAAC,IAAI,CAAC;SACb,CACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AA9CW,QAAA,2BAA2B,+BA8CtC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = computes the serialized size of a log event
|
|
3
|
+
* .why = enables amortized O(1) buffer size checks via incremental sum
|
|
4
|
+
*
|
|
5
|
+
* .note = this function is O(n) where n = serialized size.
|
|
6
|
+
* call once per send() and track sum to avoid full buffer re-serialize.
|
|
7
|
+
*/
|
|
8
|
+
export declare const computeLogEventSize: (event: object) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeLogEventSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = computes the serialized size of a log event
|
|
6
|
+
* .why = enables amortized O(1) buffer size checks via incremental sum
|
|
7
|
+
*
|
|
8
|
+
* .note = this function is O(n) where n = serialized size.
|
|
9
|
+
* call once per send() and track sum to avoid full buffer re-serialize.
|
|
10
|
+
*/
|
|
11
|
+
const computeLogEventSize = (event) => {
|
|
12
|
+
return JSON.stringify(event).length + 1; // +1 for array comma separator
|
|
13
|
+
};
|
|
14
|
+
exports.computeLogEventSize = computeLogEventSize;
|
|
15
|
+
//# sourceMappingURL=computeLogEventSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeLogEventSize.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/computeLogEventSize.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,+BAA+B;AAC1E,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogEvent } from '../../../domain.objects/LogOutlet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = extracts all events from buffer and clears it
|
|
4
|
+
* .why = extracts decode-friction from orchestrator (splice atomically removes and returns)
|
|
5
|
+
*/
|
|
6
|
+
export declare const drainBuffer: (buffer: LogEvent[]) => LogEvent[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.drainBuffer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = extracts all events from buffer and clears it
|
|
6
|
+
* .why = extracts decode-friction from orchestrator (splice atomically removes and returns)
|
|
7
|
+
*/
|
|
8
|
+
const drainBuffer = (buffer) => {
|
|
9
|
+
return buffer.splice(0, buffer.length);
|
|
10
|
+
};
|
|
11
|
+
exports.drainBuffer = drainBuffer;
|
|
12
|
+
//# sourceMappingURL=drainBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drainBuffer.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/drainBuffer.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAc,EAAE;IAC5D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LogOutlet } from '../../../domain.objects/LogOutlet';
|
|
2
|
+
/**
|
|
3
|
+
* .what = generates a CloudWatch outlet for log events
|
|
4
|
+
* .why = enables log events to flow to CloudWatch in environments without automatic collection
|
|
5
|
+
*
|
|
6
|
+
* .note = explicit opt-in: add this outlet only when automatic log collection is absent.
|
|
7
|
+
* AWS Lambda and CloudWatch Agent environments auto-collect console.log output.
|
|
8
|
+
* in those environments, omit this outlet to avoid duplicate logs.
|
|
9
|
+
*
|
|
10
|
+
* @param region - AWS region (required: from option or AWS_REGION/AWS_DEFAULT_REGION env)
|
|
11
|
+
* @param logGroup - CloudWatch log group name (default: /aws/lambda/{service}-{env})
|
|
12
|
+
* @param logStream - CloudWatch log stream name (default: Lambda-style YYYY/MM/DD/[$LATEST]uuid)
|
|
13
|
+
* @param skipLogGroupCreation - skip log group findsert (default: false)
|
|
14
|
+
* @param flushInterval - auto-flush interval in ms (default: 5000)
|
|
15
|
+
* @param maxBufferSize - buffer size threshold in bytes for force-flush (default: 256000)
|
|
16
|
+
*/
|
|
17
|
+
export declare const genCloudwatchOutlet: ({ region: regionOverride, logGroup, logStream, skipLogGroupCreation, flushInterval, maxBufferSize, }?: {
|
|
18
|
+
region?: string;
|
|
19
|
+
logGroup?: string;
|
|
20
|
+
logStream?: string;
|
|
21
|
+
skipLogGroupCreation?: boolean;
|
|
22
|
+
flushInterval?: number;
|
|
23
|
+
maxBufferSize?: number;
|
|
24
|
+
}) => LogOutlet;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genCloudwatchOutlet = void 0;
|
|
4
|
+
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
5
|
+
const asCloudWatchBatches_1 = require("./asCloudWatchBatches");
|
|
6
|
+
const asCloudWatchLogEvents_1 = require("./asCloudWatchLogEvents");
|
|
7
|
+
const asDefaultLogStreamName_1 = require("./asDefaultLogStreamName");
|
|
8
|
+
const asLambdaStyleLogGroupName_1 = require("./asLambdaStyleLogGroupName");
|
|
9
|
+
const assertAwsCredentialsPresent_1 = require("./assertAwsCredentialsPresent");
|
|
10
|
+
const computeLogEventSize_1 = require("./computeLogEventSize");
|
|
11
|
+
const drainBuffer_1 = require("./drainBuffer");
|
|
12
|
+
/**
|
|
13
|
+
* .what = generates a CloudWatch outlet for log events
|
|
14
|
+
* .why = enables log events to flow to CloudWatch in environments without automatic collection
|
|
15
|
+
*
|
|
16
|
+
* .note = explicit opt-in: add this outlet only when automatic log collection is absent.
|
|
17
|
+
* AWS Lambda and CloudWatch Agent environments auto-collect console.log output.
|
|
18
|
+
* in those environments, omit this outlet to avoid duplicate logs.
|
|
19
|
+
*
|
|
20
|
+
* @param region - AWS region (required: from option or AWS_REGION/AWS_DEFAULT_REGION env)
|
|
21
|
+
* @param logGroup - CloudWatch log group name (default: /aws/lambda/{service}-{env})
|
|
22
|
+
* @param logStream - CloudWatch log stream name (default: Lambda-style YYYY/MM/DD/[$LATEST]uuid)
|
|
23
|
+
* @param skipLogGroupCreation - skip log group findsert (default: false)
|
|
24
|
+
* @param flushInterval - auto-flush interval in ms (default: 5000)
|
|
25
|
+
* @param maxBufferSize - buffer size threshold in bytes for force-flush (default: 256000)
|
|
26
|
+
*/
|
|
27
|
+
const genCloudwatchOutlet = ({ region: regionOverride, logGroup, logStream, skipLogGroupCreation, flushInterval, maxBufferSize, } = {}) => {
|
|
28
|
+
// validate AWS credentials are present (fail-fast)
|
|
29
|
+
(0, assertAwsCredentialsPresent_1.assertAwsCredentialsPresent)();
|
|
30
|
+
// derive region (explicit > env > fail-fast)
|
|
31
|
+
const region = regionOverride ?? process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION;
|
|
32
|
+
if (!region) {
|
|
33
|
+
throw new Error('CloudWatch outlet requires AWS region. Set AWS_REGION env var or pass region option.');
|
|
34
|
+
}
|
|
35
|
+
// derive defaults
|
|
36
|
+
const logGroupName = logGroup ?? (0, asLambdaStyleLogGroupName_1.asLambdaStyleLogGroupName)();
|
|
37
|
+
const logStreamName = logStream ?? (0, asDefaultLogStreamName_1.asDefaultLogStreamName)();
|
|
38
|
+
// create client
|
|
39
|
+
const client = new client_cloudwatch_logs_1.CloudWatchLogsClient({ region });
|
|
40
|
+
// buffer for events
|
|
41
|
+
const buffer = [];
|
|
42
|
+
let bufferSize = 0; // track size incrementally for O(1) checks
|
|
43
|
+
let initialized = false;
|
|
44
|
+
let flushPromise = null;
|
|
45
|
+
// setup auto-flush with explicit crash on error
|
|
46
|
+
const intervalMs = flushInterval ?? 5000; // 5s default for faster emission
|
|
47
|
+
const bufferLimit = maxBufferSize ?? 256000; // 256KB default for frequent flushes
|
|
48
|
+
const flushTimer = setInterval(() => {
|
|
49
|
+
flush().catch((error) => {
|
|
50
|
+
console.error('CloudWatch flush failed:', error);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
}, intervalMs);
|
|
54
|
+
flushTimer.unref(); // allow process to exit despite timer
|
|
55
|
+
// register process exit hooks (beforeExit keeps event loop alive for promises)
|
|
56
|
+
const handleExitFlush = () => {
|
|
57
|
+
flush()
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
console.error('CloudWatch flush failed during exit:', error);
|
|
60
|
+
})
|
|
61
|
+
.finally(() => {
|
|
62
|
+
close();
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
process.once('beforeExit', handleExitFlush);
|
|
66
|
+
// signal handlers: flush then exit (promise chain keeps event loop alive)
|
|
67
|
+
let exitInProgress = false;
|
|
68
|
+
const handleSignalExit = (exitCode) => {
|
|
69
|
+
if (exitInProgress)
|
|
70
|
+
return;
|
|
71
|
+
exitInProgress = true;
|
|
72
|
+
flush()
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
console.error('CloudWatch flush failed during signal exit:', error);
|
|
75
|
+
})
|
|
76
|
+
.finally(() => {
|
|
77
|
+
close();
|
|
78
|
+
process.exit(exitCode);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const handleSigterm = () => handleSignalExit(143); // 128 + 15 (SIGTERM)
|
|
82
|
+
const handleSigint = () => handleSignalExit(130); // 128 + 2 (SIGINT)
|
|
83
|
+
process.once('SIGTERM', handleSigterm);
|
|
84
|
+
process.once('SIGINT', handleSigint);
|
|
85
|
+
/**
|
|
86
|
+
* .what = close the outlet and release resources
|
|
87
|
+
* .why = cleans up timers and process listeners to prevent leaks in tests
|
|
88
|
+
*/
|
|
89
|
+
const close = () => {
|
|
90
|
+
clearInterval(flushTimer);
|
|
91
|
+
process.removeListener('beforeExit', handleExitFlush);
|
|
92
|
+
process.removeListener('SIGTERM', handleSigterm);
|
|
93
|
+
process.removeListener('SIGINT', handleSigint);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* .what = findsert log group
|
|
97
|
+
* .why = idempotent creation via ResourceAlreadyExistsException
|
|
98
|
+
*/
|
|
99
|
+
const findsertLogGroup = async () => {
|
|
100
|
+
try {
|
|
101
|
+
await client.send(new client_cloudwatch_logs_1.CreateLogGroupCommand({ logGroupName }));
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error instanceof client_cloudwatch_logs_1.ResourceAlreadyExistsException)
|
|
105
|
+
return;
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* .what = findsert log stream
|
|
111
|
+
* .why = idempotent creation via ResourceAlreadyExistsException
|
|
112
|
+
*/
|
|
113
|
+
const findsertLogStream = async () => {
|
|
114
|
+
try {
|
|
115
|
+
await client.send(new client_cloudwatch_logs_1.CreateLogStreamCommand({ logGroupName, logStreamName }));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof client_cloudwatch_logs_1.ResourceAlreadyExistsException)
|
|
119
|
+
return;
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* .what = initialize log group and stream
|
|
125
|
+
* .why = lazy initialization on first flush
|
|
126
|
+
*/
|
|
127
|
+
const init = async () => {
|
|
128
|
+
if (initialized)
|
|
129
|
+
return;
|
|
130
|
+
if (!skipLogGroupCreation)
|
|
131
|
+
await findsertLogGroup();
|
|
132
|
+
await findsertLogStream();
|
|
133
|
+
initialized = true;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* .what = flush buffered events to CloudWatch
|
|
137
|
+
* .why = batch send for efficiency (max 1MB, 10k events per CloudWatch limits)
|
|
138
|
+
*
|
|
139
|
+
* .invariant = single-flush-at-a-time via flushPromise
|
|
140
|
+
* - concurrent flush() calls wait on extant flushPromise
|
|
141
|
+
* - after wait, recheck buffer for events added mid-flush
|
|
142
|
+
* - recursive call handles events that arrived while awaited
|
|
143
|
+
* - prevents concurrent PutLogEvents calls (CloudWatch sequence token issues)
|
|
144
|
+
*/
|
|
145
|
+
const flush = async () => {
|
|
146
|
+
// if no events, skip
|
|
147
|
+
if (buffer.length === 0)
|
|
148
|
+
return;
|
|
149
|
+
// if flush in progress, wait then recheck for new events
|
|
150
|
+
if (flushPromise) {
|
|
151
|
+
await flushPromise;
|
|
152
|
+
if (buffer.length > 0)
|
|
153
|
+
return flush(); // recheck for events added while wait
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// start flush
|
|
157
|
+
flushPromise = (async () => {
|
|
158
|
+
// extract events from buffer (restore on failure)
|
|
159
|
+
const events = (0, drainBuffer_1.drainBuffer)(buffer);
|
|
160
|
+
const eventsSizeSnapshot = bufferSize;
|
|
161
|
+
bufferSize = 0;
|
|
162
|
+
try {
|
|
163
|
+
await init();
|
|
164
|
+
// split into CloudWatch-compliant batches (max 1MB, 10k events each)
|
|
165
|
+
const batches = (0, asCloudWatchBatches_1.asCloudWatchBatches)(events);
|
|
166
|
+
for (const batch of batches) {
|
|
167
|
+
await client.send(new client_cloudwatch_logs_1.PutLogEventsCommand({
|
|
168
|
+
logGroupName,
|
|
169
|
+
logStreamName,
|
|
170
|
+
logEvents: (0, asCloudWatchLogEvents_1.asCloudWatchLogEvents)(batch),
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
// restore events to buffer on failure (prepend to preserve order)
|
|
176
|
+
buffer.unshift(...events);
|
|
177
|
+
bufferSize += eventsSizeSnapshot;
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
flushPromise = null;
|
|
182
|
+
}
|
|
183
|
+
})();
|
|
184
|
+
await flushPromise;
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
send: (event) => {
|
|
188
|
+
// track size incrementally (O(1) vs O(n) for full buffer stringify)
|
|
189
|
+
const eventSize = (0, computeLogEventSize_1.computeLogEventSize)(event);
|
|
190
|
+
bufferSize += eventSize;
|
|
191
|
+
buffer.push(event);
|
|
192
|
+
// force-flush if buffer exceeds size limit (explicit crash on error)
|
|
193
|
+
if (bufferSize > bufferLimit) {
|
|
194
|
+
flush().catch((error) => {
|
|
195
|
+
console.error('CloudWatch flush failed:', error);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
flush,
|
|
201
|
+
close,
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
exports.genCloudwatchOutlet = genCloudwatchOutlet;
|
|
205
|
+
//# sourceMappingURL=genCloudwatchOutlet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genCloudwatchOutlet.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.ts"],"names":[],"mappings":";;;AAAA,4EAMyC;AAIzC,+DAA4D;AAC5D,mEAAgE;AAChE,qEAAkE;AAClE,2EAAwE;AACxE,+EAA4E;AAC5E,+DAA4D;AAC5D,+CAA4C;AAE5C;;;;;;;;;;;;;;GAcG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAClC,MAAM,EAAE,cAAc,EACtB,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,aAAa,MAQX,EAAE,EAAa,EAAE;IACnB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AAC,CAAC;oBACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AA7MW,QAAA,mBAAmB,uBA6M9B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export { LogLevel } from './domain.objects/constants';
|
|
2
|
+
export type { LogEvent, LogOutlet } from './domain.objects/LogOutlet';
|
|
2
3
|
export type { ContextLogTrail, HasContextLogTrail, LogTrail, } from './domain.objects/LogTrail';
|
|
3
4
|
export { genContextLogTrail } from './domain.operations/genContextLogTrail';
|
|
4
5
|
export type { LogMethod } from './domain.operations/generateLogMethod';
|
|
5
6
|
export type { LogMethods } from './domain.operations/genLogMethods';
|
|
6
7
|
export { genLogMethods } from './domain.operations/genLogMethods';
|
|
8
|
+
export { asDefaultLogStreamName } from './domain.operations/outlets/cloudwatch/asDefaultLogStreamName';
|
|
9
|
+
export { asLambdaStyleLogGroupName } from './domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName';
|
|
10
|
+
export { genCloudwatchOutlet } from './domain.operations/outlets/cloudwatch/genCloudwatchOutlet';
|
|
7
11
|
export { withLogTrail } from './domain.operations/withLogTrail';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withLogTrail = exports.genLogMethods = exports.genContextLogTrail = exports.LogLevel = void 0;
|
|
3
|
+
exports.withLogTrail = exports.genCloudwatchOutlet = exports.asLambdaStyleLogGroupName = exports.asDefaultLogStreamName = exports.genLogMethods = exports.genContextLogTrail = exports.LogLevel = void 0;
|
|
4
4
|
var constants_1 = require("./domain.objects/constants");
|
|
5
5
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return constants_1.LogLevel; } });
|
|
6
6
|
var genContextLogTrail_1 = require("./domain.operations/genContextLogTrail");
|
|
7
7
|
Object.defineProperty(exports, "genContextLogTrail", { enumerable: true, get: function () { return genContextLogTrail_1.genContextLogTrail; } });
|
|
8
8
|
var genLogMethods_1 = require("./domain.operations/genLogMethods");
|
|
9
9
|
Object.defineProperty(exports, "genLogMethods", { enumerable: true, get: function () { return genLogMethods_1.genLogMethods; } });
|
|
10
|
+
var asDefaultLogStreamName_1 = require("./domain.operations/outlets/cloudwatch/asDefaultLogStreamName");
|
|
11
|
+
Object.defineProperty(exports, "asDefaultLogStreamName", { enumerable: true, get: function () { return asDefaultLogStreamName_1.asDefaultLogStreamName; } });
|
|
12
|
+
var asLambdaStyleLogGroupName_1 = require("./domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName");
|
|
13
|
+
Object.defineProperty(exports, "asLambdaStyleLogGroupName", { enumerable: true, get: function () { return asLambdaStyleLogGroupName_1.asLambdaStyleLogGroupName; } });
|
|
14
|
+
var genCloudwatchOutlet_1 = require("./domain.operations/outlets/cloudwatch/genCloudwatchOutlet");
|
|
15
|
+
Object.defineProperty(exports, "genCloudwatchOutlet", { enumerable: true, get: function () { return genCloudwatchOutlet_1.genCloudwatchOutlet; } });
|
|
10
16
|
var withLogTrail_1 = require("./domain.operations/withLogTrail");
|
|
11
17
|
Object.defineProperty(exports, "withLogTrail", { enumerable: true, get: function () { return withLogTrail_1.withLogTrail; } });
|
|
12
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAsD;AAA7C,qGAAA,QAAQ,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAsD;AAA7C,qGAAA,QAAQ,OAAA;AAOjB,6EAA4E;AAAnE,wHAAA,kBAAkB,OAAA;AAG3B,mEAAkE;AAAzD,8GAAA,aAAa,OAAA;AACtB,wGAAuG;AAA9F,gIAAA,sBAAsB,OAAA;AAC/B,8GAA6G;AAApG,sIAAA,yBAAyB,OAAA;AAClC,kGAAiG;AAAxF,0HAAA,mBAAmB,OAAA;AAC5B,iEAAgE;AAAvD,4GAAA,YAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "sdk-logs",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a simple and opinionated logging library. plays well with aws lambda + cloudwatch.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.8.0",
|
|
6
6
|
"repository": "ehmpathy/sdk-logs",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-logs",
|
|
8
8
|
"keywords": [
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
+
"@aws-sdk/client-cloudwatch-logs": "3.1040.0",
|
|
60
61
|
"@ehmpathy/error-fns": "^1.3.7",
|
|
61
62
|
"domain-glossary-procedure": "^1.0.0",
|
|
62
63
|
"domain-objects": "0.31.10",
|
|
@@ -83,12 +84,12 @@
|
|
|
83
84
|
"esbuild-register": "3.6.0",
|
|
84
85
|
"husky": "8.0.3",
|
|
85
86
|
"jest": "30.2.0",
|
|
86
|
-
"rhachet": "1.41.
|
|
87
|
+
"rhachet": "1.41.7",
|
|
87
88
|
"rhachet-brains-anthropic": "^0.4.1",
|
|
88
89
|
"rhachet-brains-xai": "^0.3.3",
|
|
89
90
|
"rhachet-roles-bhrain": "0.27.6",
|
|
90
|
-
"rhachet-roles-bhuild": "0.21.
|
|
91
|
-
"rhachet-roles-ehmpathy": "1.35.
|
|
91
|
+
"rhachet-roles-bhuild": "0.21.7",
|
|
92
|
+
"rhachet-roles-ehmpathy": "1.35.5",
|
|
92
93
|
"rhachet-roles-rhachet": "^0.1.7",
|
|
93
94
|
"test-fns": "1.4.2",
|
|
94
95
|
"tsc-alias": "1.8.10",
|