Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ site
tmp

# TS build files
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
tsconfig.esm.tsbuildinfo
65 changes: 14 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ Credits for the Powertools for AWS Lambda (TypeScript) idea go to [DAZN](https:/

## License

This library is licensed under the MIT-0 License. See the LICENSE file.
This library is licensed under the MIT-0 License. See the LICENSE file.
12 changes: 10 additions & 2 deletions packages/logger/jest.config.js → packages/logger/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ module.exports = {
color: 'cyan',
},
runner: 'groups',
preset: 'ts-jest',
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.ts?$': 'ts-jest',
'^.+\\.[tj]sx?$': [
'ts-jest',
{
useESM: true,
},
],
},
moduleFileExtensions: ['js', 'ts'],
collectCoverageFrom: ['**/src/**/*.ts', '!**/node_modules/**'],
Expand Down
24 changes: 20 additions & 4 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,35 @@
"test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e",
"test:e2e": "jest --group=e2e",
"watch": "jest --watch --group=unit",
"build": "tsc --build --force",
"build:cjs": "tsc --build --force",
"build:esm": "tsc --project tsconfig.esm.json",
"build": "npm run build:esm & npm run build:cjs",
"lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .",
"lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .",
"prebuild": "rimraf ./lib",
"postbuild": "node ./scripts/buildExportPackageJson.js",
"prepack": "node ../../.github/scripts/release_patch_package_json.js ."
},
"lint-staged": {
"*.{js,ts}": "npm run lint-fix"
},
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/logger#readme",
"license": "MIT-0",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"type": "module",
"exports": {
"node": {
"require": {
"types": "./lib/index.d.ts",
"default": "./lib/cjs/index.js"
},
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/esm/index.js"
}
}
},
"types": "./lib/cjs/index.d.ts",
"main": "./lib/cjs/index.js",
"devDependencies": {
"@aws-lambda-powertools/testing-utils": "file:../testing",
"@types/lodash.merge": "^4.6.7"
Expand Down Expand Up @@ -64,4 +80,4 @@
"serverless",
"nodejs"
]
}
}
19 changes: 19 additions & 0 deletions packages/logger/scripts/buildExportPackageJson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

const cjsPackageJson = '{ "type": "commonjs" }';
writeFileSync(
join(__dirname, '..', 'lib', 'cjs', 'package.json'),
cjsPackageJson,
'utf-8'
);

const esmPackageJson = '{ "type": "module" }';
writeFileSync(
join(__dirname, '..', 'lib', 'esm', 'package.json'),
esmPackageJson,
'utf-8'
);
23 changes: 13 additions & 10 deletions packages/logger/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ import { randomInt } from 'node:crypto';
import { Console } from 'node:console';
import type { Context, Handler } from 'aws-lambda';
import { Utility } from '@aws-lambda-powertools/commons';
import { LogFormatterInterface, PowertoolsLogFormatter } from './formatter';
import { LogItem } from './log';
import { PowertoolsLogFormatter } from './formatter/PowertoolsLogFormatter.js';
import { LogFormatterInterface } from './formatter/LogFormatterInterface.js';
import { LogItem } from './log/LogItem.js';
import merge from 'lodash.merge';
import { ConfigServiceInterface, EnvironmentVariablesService } from './config';
import { LogJsonIndent } from './types';
import { ConfigServiceInterface } from './config/ConfigServiceInterface.js';
import { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js';
import { LogJsonIndent } from './types/Logger.js';
import type {
ClassThatLogs,
Environment,
LogAttributes,
LogLevel,
LogLevelThresholds,
} from './types/Log.js';
import type {
ClassThatLogs,
HandlerMethodDecorator,
LambdaFunctionContext,
LogAttributes,
ConstructorOptions,
LogItemExtraInput,
LogItemMessage,
LogLevel,
LogLevelThresholds,
PowertoolLogData,
HandlerOptions,
} from './types';

} from './types/Logger.js';
/**
* ## Intro
* The Logger utility provides an opinionated logger with output structured as JSON.
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/src/config/EnvironmentVariablesService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigServiceInterface } from './ConfigServiceInterface';
import { ConfigServiceInterface } from './ConfigServiceInterface.js';
import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';

/**
Expand Down
2 changes: 0 additions & 2 deletions packages/logger/src/config/index.ts

This file was deleted.

7 changes: 4 additions & 3 deletions packages/logger/src/formatter/LogFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LogFormatterInterface } from '.';
import { LogAttributes, UnformattedAttributes } from '../types';
import { LogItem } from '../log';
import { LogFormatterInterface } from './LogFormatterInterface.js';
import { LogAttributes } from '../types/Log.js';
import { UnformattedAttributes } from '../types/Logger.js';
import { LogItem } from '../log/LogItem.js';

/**
* Typeguard to monkey patch Error to add a cause property.
Expand Down
Loading