sdk-logs 0.9.0 → 0.9.2
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/LogMethods.d.ts +46 -0
- package/dist/domain.objects/LogMethods.js +3 -0
- package/dist/domain.objects/LogMethods.js.map +1 -0
- package/dist/domain.objects/LogTrail.d.ts +1 -1
- package/dist/domain.operations/genLogMethods.d.ts +2 -38
- package/dist/domain.operations/genLogMethods.js.map +1 -1
- package/dist/domain.operations/generateLogMethod.d.ts +1 -1
- package/dist/domain.operations/generateLogMethod.js +7 -0
- package/dist/domain.operations/generateLogMethod.js.map +1 -1
- package/dist/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.js +2 -2
- package/dist/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.js.map +1 -1
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.d.ts +30 -7
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.js +18 -15
- package/dist/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +32 -25
- package/readme.md +22 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Environment } from 'sdk-environment';
|
|
2
|
+
import type { LogLevel } from '../domain.objects/constants';
|
|
3
|
+
/**
|
|
4
|
+
* .what = a log method that outputs a message with optional metadata
|
|
5
|
+
*/
|
|
6
|
+
export type LogMethod = (message: string, metadata?: any) => void;
|
|
7
|
+
/**
|
|
8
|
+
* .what = the log methods available for use
|
|
9
|
+
*/
|
|
10
|
+
export interface LogMethods {
|
|
11
|
+
/**
|
|
12
|
+
* `error` level logs are used to indicate a critical and urgent failure that requires immediate resolution
|
|
13
|
+
* - these logs are often associated with someone on-call being notified immediately, regardless of the time or day
|
|
14
|
+
* - when choosing to log something with a log level of "error", you are saying that someone should be woken up in the middle of the night if this occurs
|
|
15
|
+
*/
|
|
16
|
+
error: LogMethod;
|
|
17
|
+
/**
|
|
18
|
+
* `warn` level logs are used to indicate that something is going wrong, but can wait to be resolved until a convenient time
|
|
19
|
+
* - these logs are often associated with someone following up on them during business hours
|
|
20
|
+
* - when choosing to log something with a log level of "warn", you are saying that someone should look at this as soon as reasonably possible
|
|
21
|
+
*/
|
|
22
|
+
warn: LogMethod;
|
|
23
|
+
/**
|
|
24
|
+
* `info` level logs are used to indicate an interesting event that should be kept track of
|
|
25
|
+
* - these logs are often associated with health metrics, dashboard statistics, or custom log queries for investigations or reporting
|
|
26
|
+
* - when choosing to log something with a log level of "info", you are saying that someone will be interested in this information indefinitely
|
|
27
|
+
*/
|
|
28
|
+
info: LogMethod;
|
|
29
|
+
/**
|
|
30
|
+
* `debug` level logs are used to output information that can aid users in tracking down bugs or confirming that things are working as expected
|
|
31
|
+
* - these logs are often associated with common actions that happen within code, that may only be relevant when debugging your applications
|
|
32
|
+
* - when choosing to log something with a log level of "debug", you are saying that someone will only be interested in this information when debugging
|
|
33
|
+
*/
|
|
34
|
+
debug: LogMethod;
|
|
35
|
+
/**
|
|
36
|
+
* .what = internal config for log methods
|
|
37
|
+
*/
|
|
38
|
+
readonly _: Readonly<{
|
|
39
|
+
level: LogLevel;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* .what = the environment context baked into these log methods
|
|
43
|
+
* .why = enables withLogTrail to inherit env from outer log
|
|
44
|
+
*/
|
|
45
|
+
readonly env?: Partial<Environment>;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogMethods.js","sourceRoot":"","sources":["../../src/domain.objects/LogMethods.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Procedure, ProcedureContext } from 'domain-glossary-procedure';
|
|
2
2
|
import type { Environment } from 'sdk-environment';
|
|
3
|
-
import type { LogMethods } from '../domain.
|
|
3
|
+
import type { LogMethods } from '../domain.objects/LogMethods';
|
|
4
4
|
/**
|
|
5
5
|
* .what = the procedure invocation trail with external identifier
|
|
6
6
|
*/
|
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
import type { Environment } from 'sdk-environment';
|
|
2
2
|
import { LogLevel } from '../domain.objects/constants';
|
|
3
|
+
import type { LogMethods } from '../domain.objects/LogMethods';
|
|
3
4
|
import type { LogOutlet } from '../domain.objects/LogOutlet';
|
|
4
|
-
|
|
5
|
-
export interface LogMethods {
|
|
6
|
-
/**
|
|
7
|
-
* `error` level logs are used to indicate a critical and urgent failure that requires immediate resolution
|
|
8
|
-
* - these logs are often associated with someone on-call being notified immediately, regardless of the time or day
|
|
9
|
-
* - when choosing to log something with a log level of "error", you are saying that someone should be woken up in the middle of the night if this occurs
|
|
10
|
-
*/
|
|
11
|
-
error: LogMethod;
|
|
12
|
-
/**
|
|
13
|
-
* `warn` level logs are used to indicate that something is going wrong, but can wait to be resolved until a convenient time
|
|
14
|
-
* - these logs are often associated with someone following up on them during business hours
|
|
15
|
-
* - when choosing to log something with a log level of "warn", you are saying that someone should look at this as soon as reasonably possible
|
|
16
|
-
*/
|
|
17
|
-
warn: LogMethod;
|
|
18
|
-
/**
|
|
19
|
-
* `info` level logs are used to indicate an interesting event that should be kept track of
|
|
20
|
-
* - these logs are often associated with health metrics, dashboard statistics, or custom log queries for investigations or reporting
|
|
21
|
-
* - when choosing to log something with a log level of "info", you are saying that someone will be interested in this information indefinitely
|
|
22
|
-
*/
|
|
23
|
-
info: LogMethod;
|
|
24
|
-
/**
|
|
25
|
-
* `debug` level logs are used to output information that can aid users in tracking down bugs or confirming that things are working as expected
|
|
26
|
-
* - these logs are often associated with common actions that happen within code, that may only be relevant when debugging your applications
|
|
27
|
-
* - when choosing to log something with a log level of "debug", you are saying that someone will only be interested in this information when debugging
|
|
28
|
-
*/
|
|
29
|
-
debug: LogMethod;
|
|
30
|
-
/**
|
|
31
|
-
* .what = internal config for log methods
|
|
32
|
-
*/
|
|
33
|
-
readonly _: Readonly<{
|
|
34
|
-
level: LogLevel;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* .what = the environment context baked into these log methods
|
|
38
|
-
* .why = enables withLogTrail to inherit env from outer log
|
|
39
|
-
*/
|
|
40
|
-
readonly env?: Partial<Environment>;
|
|
41
|
-
}
|
|
5
|
+
export type { LogMethod, LogMethods } from '../domain.objects/LogMethods';
|
|
42
6
|
/**
|
|
43
7
|
* define how to generate the log methods
|
|
44
8
|
* - allows you to specify the minimal log level to use for your application
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/genLogMethods.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"genLogMethods.js","sourceRoot":"","sources":["../../src/domain.operations/genLogMethods.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAIzD,2DAAwD;AACxD,+GAA4G;AAK5G;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,EAC5B,KAAK,EACL,OAAO,EACP,GAAG,MAKD,EAAE,EAAc,EAAE;IACpB,2BAA2B;IAC3B,MAAM,sBAAsB,GAC1B,KAAK,EAAE,OAAO,IAAI,IAAA,yFAA2C,GAAE,CAAC;IAElE,6CAA6C;IAC7C,MAAM,SAAS,GAAG,GAAG,IAAI,SAAS,CAAC;IAEnC,uBAAuB;IACvB,OAAO;QACL,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe,EAAE,sBAAsB;YACvC,OAAO;YACP,GAAG,EAAE,SAAS;SACf,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe,EAAE,sBAAsB;YACvC,OAAO;YACP,GAAG,EAAE,SAAS;SACf,CAAC;QACF,IAAI,EAAE,IAAA,qCAAiB,EAAC;YACtB,KAAK,EAAE,oBAAQ,CAAC,IAAI;YACpB,eAAe,EAAE,sBAAsB;YACvC,OAAO;YACP,GAAG,EAAE,SAAS;SACf,CAAC;QACF,KAAK,EAAE,IAAA,qCAAiB,EAAC;YACvB,KAAK,EAAE,oBAAQ,CAAC,KAAK;YACrB,eAAe,EAAE,sBAAsB;YACvC,OAAO;YACP,GAAG,EAAE,SAAS;SACf,CAAC;QACF,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;QACnD,GAAG,EAAE,SAAS;KACf,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,aAAa,iBA6CxB"}
|
|
@@ -2,7 +2,7 @@ import type { Environment } from 'sdk-environment';
|
|
|
2
2
|
import { LogLevel } from '../domain.objects/constants';
|
|
3
3
|
import type { LogOutlet } from '../domain.objects/LogOutlet';
|
|
4
4
|
import type { LogTrail } from '../domain.objects/LogTrail';
|
|
5
|
-
export type LogMethod
|
|
5
|
+
export type { LogMethod } from '../domain.objects/LogMethods';
|
|
6
6
|
export declare const generateLogMethod: ({ level, minimalLogLevel, trail, env, outlets, }: {
|
|
7
7
|
level: LogLevel;
|
|
8
8
|
minimalLogLevel: LogLevel;
|
|
@@ -14,6 +14,13 @@ const logLevelPriorityOrder = [
|
|
|
14
14
|
constants_1.LogLevel.DEBUG,
|
|
15
15
|
];
|
|
16
16
|
const aIsEqualOrMoreImportantThanB = ({ a, b }) => logLevelPriorityOrder.indexOf(a) - logLevelPriorityOrder.indexOf(b) <= 0;
|
|
17
|
+
/*
|
|
18
|
+
define how to generate a log method
|
|
19
|
+
- i.e.,:
|
|
20
|
+
- define when allowed to emit a log (i.e., when level > minimalLogLevel)
|
|
21
|
+
- define the format of the log message (json w/ level, timestamp, message, metadata)
|
|
22
|
+
- define the transport of the message (console.log / console.warn)
|
|
23
|
+
*/
|
|
17
24
|
const generateLogMethod = ({ level, minimalLogLevel, trail, env, outlets, }) => {
|
|
18
25
|
return (message, metadata) => {
|
|
19
26
|
// check level threshold
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAIzD,mEAAgE;AAChE,uFAAoF;
|
|
1
|
+
{"version":3,"file":"generateLogMethod.js","sourceRoot":"","sources":["../../src/domain.operations/generateLogMethod.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAIzD,mEAAgE;AAChE,uFAAoF;AAKpF;;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;AAE3E;;;;;;EAME;AACK,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;gBACzD,GAAG;aACJ,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;AAtDW,QAAA,iBAAiB,qBAsD5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertAwsCredentialsPresent = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
5
|
/**
|
|
6
6
|
* .what = validates AWS credentials are available via common sources
|
|
7
7
|
* .why = fail-fast at outlet creation rather than on first flush
|
|
@@ -30,7 +30,7 @@ const assertAwsCredentialsPresent = () => {
|
|
|
30
30
|
!hasWebIdentity &&
|
|
31
31
|
!hasContainerCredentials &&
|
|
32
32
|
!hasMetadataService) {
|
|
33
|
-
throw new
|
|
33
|
+
throw new helpful_errors_1.BadRequestError('AWS credentials not configured. genCloudwatchOutlet requires valid AWS credentials.', {
|
|
34
34
|
hint: [
|
|
35
35
|
'configure credentials via one of:',
|
|
36
36
|
' - env: AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertAwsCredentialsPresent.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"assertAwsCredentialsPresent.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/assertAwsCredentialsPresent.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;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,gCAAe,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"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import type { CloudWatchLogsClient, CreateLogGroupCommand, CreateLogStreamCommand, PutLogEventsCommand, ResourceAlreadyExistsException } from '@aws-sdk/client-cloudwatch-logs';
|
|
1
2
|
import type { LogOutlet } from '../../../domain.objects/LogOutlet';
|
|
3
|
+
/**
|
|
4
|
+
* .what = the AWS CloudWatch Logs SDK module
|
|
5
|
+
* .why = dependency injection removes runtime AWS SDK dependency from sdk-logs
|
|
6
|
+
*
|
|
7
|
+
* .usage
|
|
8
|
+
* import * as sdkAwsCloudwatch from '@aws-sdk/client-cloudwatch-logs';
|
|
9
|
+
* genCloudwatchOutlet({ ... }, { cloudwatch: { sdk: sdkAwsCloudwatch } });
|
|
10
|
+
*/
|
|
11
|
+
export type SdkAwsCloudwatch = {
|
|
12
|
+
CloudWatchLogsClient: typeof CloudWatchLogsClient;
|
|
13
|
+
CreateLogGroupCommand: typeof CreateLogGroupCommand;
|
|
14
|
+
CreateLogStreamCommand: typeof CreateLogStreamCommand;
|
|
15
|
+
PutLogEventsCommand: typeof PutLogEventsCommand;
|
|
16
|
+
ResourceAlreadyExistsException: typeof ResourceAlreadyExistsException;
|
|
17
|
+
};
|
|
2
18
|
/**
|
|
3
19
|
* .what = generates a CloudWatch outlet for log events
|
|
4
20
|
* .why = enables log events to flow to CloudWatch in environments without automatic collection
|
|
@@ -7,18 +23,25 @@ import type { LogOutlet } from '../../../domain.objects/LogOutlet';
|
|
|
7
23
|
* AWS Lambda and CloudWatch Agent environments auto-collect console.log output.
|
|
8
24
|
* in those environments, omit this outlet to avoid duplicate logs.
|
|
9
25
|
*
|
|
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)
|
|
26
|
+
* @param input.region - AWS region (required: from option or AWS_REGION/AWS_DEFAULT_REGION env)
|
|
27
|
+
* @param input.logGroup - CloudWatch log group name (default: /aws/lambda/{service}-{env})
|
|
28
|
+
* @param input.logStream - CloudWatch log stream name (default: Lambda-style YYYY/MM/DD/[$LATEST]uuid)
|
|
29
|
+
* @param input.skipLogGroupCreation - skip log group findsert (default: false)
|
|
30
|
+
* @param input.flushInterval - auto-flush interval in ms (default: 5000)
|
|
31
|
+
* @param input.maxBufferSize - buffer size threshold in bytes for force-flush (default: 256000)
|
|
32
|
+
* @param context.cloudwatch.sdk - the @aws-sdk/client-cloudwatch-logs module
|
|
33
|
+
* @param context.cloudwatch.client - optional pre-configured CloudWatchLogsClient
|
|
16
34
|
*/
|
|
17
|
-
export declare const genCloudwatchOutlet: (
|
|
35
|
+
export declare const genCloudwatchOutlet: (input: {
|
|
18
36
|
region?: string;
|
|
19
37
|
logGroup?: string;
|
|
20
38
|
logStream?: string;
|
|
21
39
|
skipLogGroupCreation?: boolean;
|
|
22
40
|
flushInterval?: number;
|
|
23
41
|
maxBufferSize?: number;
|
|
42
|
+
}, context: {
|
|
43
|
+
cloudwatch: {
|
|
44
|
+
sdk: SdkAwsCloudwatch;
|
|
45
|
+
client?: CloudWatchLogsClient;
|
|
46
|
+
};
|
|
24
47
|
}) => LogOutlet;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.genCloudwatchOutlet = void 0;
|
|
4
|
-
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
5
4
|
const asCloudWatchBatches_1 = require("./asCloudWatchBatches");
|
|
6
5
|
const asCloudWatchLogEvents_1 = require("./asCloudWatchLogEvents");
|
|
7
6
|
const asDefaultLogStreamName_1 = require("./asDefaultLogStreamName");
|
|
@@ -17,14 +16,18 @@ const drainBuffer_1 = require("./drainBuffer");
|
|
|
17
16
|
* AWS Lambda and CloudWatch Agent environments auto-collect console.log output.
|
|
18
17
|
* in those environments, omit this outlet to avoid duplicate logs.
|
|
19
18
|
*
|
|
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)
|
|
19
|
+
* @param input.region - AWS region (required: from option or AWS_REGION/AWS_DEFAULT_REGION env)
|
|
20
|
+
* @param input.logGroup - CloudWatch log group name (default: /aws/lambda/{service}-{env})
|
|
21
|
+
* @param input.logStream - CloudWatch log stream name (default: Lambda-style YYYY/MM/DD/[$LATEST]uuid)
|
|
22
|
+
* @param input.skipLogGroupCreation - skip log group findsert (default: false)
|
|
23
|
+
* @param input.flushInterval - auto-flush interval in ms (default: 5000)
|
|
24
|
+
* @param input.maxBufferSize - buffer size threshold in bytes for force-flush (default: 256000)
|
|
25
|
+
* @param context.cloudwatch.sdk - the @aws-sdk/client-cloudwatch-logs module
|
|
26
|
+
* @param context.cloudwatch.client - optional pre-configured CloudWatchLogsClient
|
|
26
27
|
*/
|
|
27
|
-
const genCloudwatchOutlet = (
|
|
28
|
+
const genCloudwatchOutlet = (input, context) => {
|
|
29
|
+
const { region: regionOverride, logGroup, logStream, skipLogGroupCreation, flushInterval, maxBufferSize, } = input;
|
|
30
|
+
const { CloudWatchLogsClient: CloudWatchLogsClientClass, CreateLogGroupCommand, CreateLogStreamCommand, PutLogEventsCommand, ResourceAlreadyExistsException, } = context.cloudwatch.sdk;
|
|
28
31
|
// validate AWS credentials are present (fail-fast)
|
|
29
32
|
(0, assertAwsCredentialsPresent_1.assertAwsCredentialsPresent)();
|
|
30
33
|
// derive region (explicit > env > fail-fast)
|
|
@@ -35,8 +38,8 @@ const genCloudwatchOutlet = ({ region: regionOverride, logGroup, logStream, skip
|
|
|
35
38
|
// derive defaults
|
|
36
39
|
const logGroupName = logGroup ?? (0, asLambdaStyleLogGroupName_1.asLambdaStyleLogGroupName)();
|
|
37
40
|
const logStreamName = logStream ?? (0, asDefaultLogStreamName_1.asDefaultLogStreamName)();
|
|
38
|
-
// create
|
|
39
|
-
const client = new
|
|
41
|
+
// use provided client or create from sdk (sdk uses AWS_REGION env var)
|
|
42
|
+
const client = context.cloudwatch.client ?? new CloudWatchLogsClientClass({});
|
|
40
43
|
// buffer for events
|
|
41
44
|
const buffer = [];
|
|
42
45
|
let bufferSize = 0; // track size incrementally for O(1) checks
|
|
@@ -98,10 +101,10 @@ const genCloudwatchOutlet = ({ region: regionOverride, logGroup, logStream, skip
|
|
|
98
101
|
*/
|
|
99
102
|
const findsertLogGroup = async () => {
|
|
100
103
|
try {
|
|
101
|
-
await client.send(new
|
|
104
|
+
await client.send(new CreateLogGroupCommand({ logGroupName }));
|
|
102
105
|
}
|
|
103
106
|
catch (error) {
|
|
104
|
-
if (error instanceof
|
|
107
|
+
if (error instanceof ResourceAlreadyExistsException)
|
|
105
108
|
return;
|
|
106
109
|
throw error;
|
|
107
110
|
}
|
|
@@ -112,10 +115,10 @@ const genCloudwatchOutlet = ({ region: regionOverride, logGroup, logStream, skip
|
|
|
112
115
|
*/
|
|
113
116
|
const findsertLogStream = async () => {
|
|
114
117
|
try {
|
|
115
|
-
await client.send(new
|
|
118
|
+
await client.send(new CreateLogStreamCommand({ logGroupName, logStreamName }));
|
|
116
119
|
}
|
|
117
120
|
catch (error) {
|
|
118
|
-
if (error instanceof
|
|
121
|
+
if (error instanceof ResourceAlreadyExistsException)
|
|
119
122
|
return;
|
|
120
123
|
throw error;
|
|
121
124
|
}
|
|
@@ -164,7 +167,7 @@ const genCloudwatchOutlet = ({ region: regionOverride, logGroup, logStream, skip
|
|
|
164
167
|
// split into CloudWatch-compliant batches (max 1MB, 10k events each)
|
|
165
168
|
const batches = (0, asCloudWatchBatches_1.asCloudWatchBatches)(events);
|
|
166
169
|
for (const batch of batches) {
|
|
167
|
-
await client.send(new
|
|
170
|
+
await client.send(new PutLogEventsCommand({
|
|
168
171
|
logGroupName,
|
|
169
172
|
logStreamName,
|
|
170
173
|
logEvents: (0, asCloudWatchLogEvents_1.asCloudWatchLogEvents)(batch),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genCloudwatchOutlet.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"genCloudwatchOutlet.js","sourceRoot":"","sources":["../../../../src/domain.operations/outlets/cloudwatch/genCloudwatchOutlet.ts"],"names":[],"mappings":";;;AA0BA,+DAA4D;AAC5D,mEAAgE;AAChE,qEAAkE;AAClE,2EAAwE;AACxE,+EAA4E;AAC5E,+DAA4D;AAC5D,+CAA4C;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAOC,EACD,OAKC,EACU,EAAE;IACb,MAAM,EACJ,MAAM,EAAE,cAAc,EACtB,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,aAAa,GACd,GAAG,KAAK,CAAC;IAEV,MAAM,EACJ,oBAAoB,EAAE,yBAAyB,EAC/C,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,8BAA8B,GAC/B,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;IAE3B,mDAAmD;IACnD,IAAA,yDAA2B,GAAE,CAAC;IAE9B,6CAA6C;IAC7C,MAAM,MAAM,GACV,cAAc,IAAI,OAAO,CAAC,G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C;YACL,CAAC;QACH,CAAC;QACD,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AA/NW,QAAA,mBAAmB,uBA+N9B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export type { LogMethods } from './domain.operations/genLogMethods';
|
|
|
7
7
|
export { genLogMethods } from './domain.operations/genLogMethods';
|
|
8
8
|
export { asDefaultLogStreamName } from './domain.operations/outlets/cloudwatch/asDefaultLogStreamName';
|
|
9
9
|
export { asLambdaStyleLogGroupName } from './domain.operations/outlets/cloudwatch/asLambdaStyleLogGroupName';
|
|
10
|
-
export { genCloudwatchOutlet } from './domain.operations/outlets/cloudwatch/genCloudwatchOutlet';
|
|
10
|
+
export { genCloudwatchOutlet, type SdkAwsCloudwatch, } from './domain.operations/outlets/cloudwatch/genCloudwatchOutlet';
|
|
11
11
|
export { withLogTrail } from './domain.operations/withLogTrail';
|
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;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,
|
|
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,kGAGoE;AAFlE,0HAAA,mBAAmB,OAAA;AAGrB,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.9.
|
|
5
|
+
"version": "0.9.2",
|
|
6
6
|
"repository": "ehmpathy/sdk-logs",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-logs",
|
|
8
8
|
"keywords": [
|
|
@@ -32,8 +32,11 @@
|
|
|
32
32
|
"fix:format": "npm run fix:format:biome",
|
|
33
33
|
"fix:lint": "biome check --write",
|
|
34
34
|
"fix": "npm run fix:format && npm run fix:lint",
|
|
35
|
-
"build:clean": "
|
|
36
|
-
"build:
|
|
35
|
+
"build:clean:bun": "rm -f ./bin/*.bc",
|
|
36
|
+
"build:clean:tsc": "(chmod -R u+w dist 2>/dev/null || true) && rm -rf dist/",
|
|
37
|
+
"build:clean": "npm run build:clean:tsc && npm run build:clean:bun",
|
|
38
|
+
"build:compile:tsc": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
39
|
+
"build:compile": "npm run build:compile:tsc && npm run build:compile:bun --if-present",
|
|
37
40
|
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
38
41
|
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
39
42
|
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
@@ -42,34 +45,36 @@
|
|
|
42
45
|
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
43
46
|
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
44
47
|
"test:lint:biome:all": "biome check",
|
|
45
|
-
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
46
|
-
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -
|
|
47
|
-
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -
|
|
48
|
-
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([
|
|
49
|
-
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
50
|
-
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
48
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:cycles && npm run test:lint:deps",
|
|
49
|
+
"test:unit": "set -eu && jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ \"${THOROUGH:-}\" != \"true\" ] && echo '--changedSince=main') $([ \"${RESNAP:-}\" = \"true\" ] && echo '--updateSnapshot')",
|
|
50
|
+
"test:integration": "set -eu && jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ \"${THOROUGH:-}\" != \"true\" ] && echo '--changedSince=main') $([ \"${RESNAP:-}\" = \"true\" ] && echo '--updateSnapshot')",
|
|
51
|
+
"test:acceptance:locally": "set -eu && npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ \"${RESNAP:-}\" = \"true\" ] && echo '--updateSnapshot')",
|
|
52
|
+
"test": "set -eu && npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
53
|
+
"test:acceptance": "set -eu && npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n \"${CI:-}\" ] && echo '--ci') $([ \"${RESNAP:-}\" = \"true\" ] && echo '--updateSnapshot')",
|
|
51
54
|
"prepush": "npm run test && npm run build",
|
|
52
55
|
"prepublish": "npm run build",
|
|
53
56
|
"preversion": "npm run prepush",
|
|
54
57
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
55
58
|
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
56
|
-
"prepare:rhachet": "rhachet init --hooks --roles mechanic behaver driver
|
|
57
|
-
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi"
|
|
59
|
+
"prepare:rhachet": "rhachet init --hooks --roles mechanic behaver driver architect ergonomist reviewer dreamer dispatcher",
|
|
60
|
+
"prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi",
|
|
61
|
+
"test:lint:cycles": "dpdm -T --no-warning --no-tree --exit-code circular:1 --exclude \"$(yq -r '.exclude | join(\"|\") // \"^$\"' .dpdmrc.yaml)\" 'src/**/!(*.test).ts'",
|
|
62
|
+
"upgrade:rhachet": "rhachet upgrade"
|
|
58
63
|
},
|
|
59
64
|
"dependencies": {
|
|
60
|
-
"@aws-sdk/client-cloudwatch-logs": "3.1040.0",
|
|
61
65
|
"@ehmpathy/error-fns": "^1.3.7",
|
|
62
66
|
"domain-glossary-procedure": "^1.0.0",
|
|
63
|
-
"domain-objects": "0.31.
|
|
67
|
+
"domain-objects": "0.31.13",
|
|
64
68
|
"helpful-errors": "1.7.3",
|
|
65
69
|
"iso-time": "^1.11.5",
|
|
66
|
-
"sdk-environment": "0.1.3",
|
|
67
70
|
"type-fns": "1.21.2"
|
|
68
71
|
},
|
|
69
72
|
"devDependencies": {
|
|
73
|
+
"@aws-sdk/client-cloudwatch-logs": "3.1063.0",
|
|
70
74
|
"@biomejs/biome": "2.3.8",
|
|
71
75
|
"@commitlint/cli": "19.5.0",
|
|
72
76
|
"@commitlint/config-conventional": "19.5.0",
|
|
77
|
+
"@jest/globals": "30.2.0",
|
|
73
78
|
"@swc/core": "1.15.3",
|
|
74
79
|
"@swc/jest": "0.2.39",
|
|
75
80
|
"@tsconfig/node20": "20.1.5",
|
|
@@ -77,22 +82,24 @@
|
|
|
77
82
|
"@types/jest": "30.0.0",
|
|
78
83
|
"@types/node": "22.15.21",
|
|
79
84
|
"cz-conventional-changelog": "3.3.0",
|
|
80
|
-
"declapract": "^0.13.
|
|
81
|
-
"declapract-typescript-ehmpathy": "^0.47.
|
|
82
|
-
"declastruct": "1.
|
|
83
|
-
"declastruct-github": "1.
|
|
85
|
+
"declapract": "^0.13.21",
|
|
86
|
+
"declapract-typescript-ehmpathy": "^0.47.74",
|
|
87
|
+
"declastruct": "1.9.1",
|
|
88
|
+
"declastruct-github": "1.4.0",
|
|
84
89
|
"depcheck": "1.4.3",
|
|
90
|
+
"dpdm": "4.0.1",
|
|
85
91
|
"esbuild-register": "3.6.0",
|
|
86
92
|
"husky": "8.0.3",
|
|
87
93
|
"jest": "30.2.0",
|
|
88
|
-
"rhachet": "1.41.
|
|
89
|
-
"rhachet-brains-anthropic": "
|
|
90
|
-
"rhachet-brains-xai": "
|
|
91
|
-
"rhachet-roles-bhrain": "0.
|
|
92
|
-
"rhachet-roles-bhuild": "0.21.
|
|
93
|
-
"rhachet-roles-ehmpathy": "1.35.
|
|
94
|
+
"rhachet": "1.41.18",
|
|
95
|
+
"rhachet-brains-anthropic": "0.4.1",
|
|
96
|
+
"rhachet-brains-xai": "0.3.3",
|
|
97
|
+
"rhachet-roles-bhrain": "0.29.0",
|
|
98
|
+
"rhachet-roles-bhuild": "0.21.15",
|
|
99
|
+
"rhachet-roles-ehmpathy": "1.35.12",
|
|
94
100
|
"rhachet-roles-rhachet": "^0.1.7",
|
|
95
|
-
"
|
|
101
|
+
"sdk-environment": "0.1.5",
|
|
102
|
+
"test-fns": "1.15.8",
|
|
96
103
|
"tsc-alias": "1.8.10",
|
|
97
104
|
"tsx": "4.20.6",
|
|
98
105
|
"typescript": "5.4.5",
|
package/readme.md
CHANGED
|
@@ -43,3 +43,25 @@ log.info(`we either want to or should keep track of this`, metadata); // use `.i
|
|
|
43
43
|
|
|
44
44
|
log.debug(`this will help debug if things go wrong`, metadata); // use this for any information that could help debug when things go wrong (e.g., request/response data)
|
|
45
45
|
```
|
|
46
|
+
|
|
47
|
+
### cloudwatch outlet
|
|
48
|
+
|
|
49
|
+
for environments without automatic log collection (e.g., non-Lambda compute), you can forward logs directly to CloudWatch:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import * as sdkAwsCloudwatch from '@aws-sdk/client-cloudwatch-logs';
|
|
53
|
+
import { genCloudwatchOutlet, genLogMethods } from 'sdk-logs';
|
|
54
|
+
|
|
55
|
+
const outlet = genCloudwatchOutlet(
|
|
56
|
+
{ region: 'us-east-1' },
|
|
57
|
+
{ cloudwatch: { sdk: sdkAwsCloudwatch } },
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const log = genLogMethods({ outlets: [outlet] });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
note: the AWS SDK is injected via context to keep it as a peer dependency. install it separately:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm install --save @aws-sdk/client-cloudwatch-logs
|
|
67
|
+
```
|