{"id":18106,"library":"amplify-cli-logger","title":"Amplify CLI Logger","description":"Amplify CLI Logger v1.2.3 is a logging utility internal to the AWS Amplify CLI ecosystem. It provides structured logging for Amplify CLI commands and plugins, with support for multiple log levels and output formatting. Released as part of the AWS Amplify CLI monorepo, it is tightly coupled to the Amplify CLI runtime and is not intended for standalone use. The package ships TypeScript types and is distributed via npm under the @aws-amplify scope. It is currently in active development alongside the Amplify CLI, with releases aligned to the CLI's major version (currently v14.x). Key differentiators include integration with Amplify CLI's context object and automatic log level configuration based on CLI verbosity settings.","status":"active","version":"1.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/aws-amplify/amplify-cli","tags":["javascript","typescript"],"install":[{"cmd":"npm install amplify-cli-logger","lang":"bash","label":"npm"},{"cmd":"yarn add amplify-cli-logger","lang":"bash","label":"yarn"},{"cmd":"pnpm add amplify-cli-logger","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides core Amplify CLI types and context interfaces used by the logger","package":"@aws-amplify/cli-core","optional":false}],"imports":[{"note":"This is a named export, not a default export. Using default import will result in undefined.","wrong":"import AmplifyLogger from '@aws-amplify/amplify-cli-logger'","symbol":"AmplifyLogger","correct":"import { AmplifyLogger } from '@aws-amplify/amplify-cli-logger'"},{"note":"The enum is named LogLevel, not LogLevels. Available values: DEBUG, INFO, WARN, ERROR.","wrong":"import { LogLevels } from '@aws-amplify/amplify-cli-logger'","symbol":"LogLevel","correct":"import { LogLevel } from '@aws-amplify/amplify-cli-logger'"},{"note":"This package is ESM-only. require() will fail unless you use a compatible Node version with esm resolution.","wrong":"const { getAmplifyLogger } = require('@aws-amplify/amplify-cli-logger')","symbol":"getAmplifyLogger","correct":"import { getAmplifyLogger } from '@aws-amplify/amplify-cli-logger'"}],"quickstart":{"code":"import { AmplifyLogger, LogLevel } from '@aws-amplify/amplify-cli-logger';\n\nconst logger = new AmplifyLogger({\n  logLevel: process.env.VERBOSE ? LogLevel.DEBUG : LogLevel.INFO,\n  outputStream: process.stdout\n});\n\nlogger.info('Amplify CLI initialized', { timestamp: new Date().toISOString() });\nlogger.debug('Verbose debugging info', { details: 'some context' });\n\ntry {\n  // risky operation\n  throw new Error('Operation failed');\n} catch (err) {\n  logger.error('An error occurred', { error: (err as Error).message });\n}\n\n// Cleanup\nlogger.close();","lang":"typescript","description":"Shows creating a logger instance with configurable log level, logging messages at different levels including structured metadata, and proper cleanup."},"warnings":[{"fix":"Use import statements or dynamic import(). If you must use CommonJS, use a dynamic import wrapper: const { AmplifyLogger } = await import('@aws-amplify/amplify-cli-logger');","message":"The package is ESM-only starting from v1.2.0. require() will throw a MODULE_NOT_FOUND error.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Replace { level: LogLevel.INFO } with { logLevel: LogLevel.INFO }.","message":"Constructor parameter 'logLevel' was renamed from 'level' in v1.1.0.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use getAmplifyLogger() factory function instead which properly initializes the logger with the current CLI context.","message":"The logger is not designed for direct instantiation outside Amplify CLI context. It expects an AmplifyContext object with specific properties.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"","message":"LogLevel enum values are strings ('DEBUG', 'INFO', 'WARN', 'ERROR'), not numbers. Comparing with === will work correctly but type narrowing may behave differently.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change the import to use ESM syntax: import { AmplifyLogger } from '@aws-amplify/amplify-cli-logger'; Or use dynamic import: const { AmplifyLogger } = await import('@aws-amplify/amplify-cli-logger');","cause":"The package is ESM-only and cannot be loaded with require().","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/@aws-amplify/amplify-cli-logger/dist/index.js from /path/to/project/index.js not supported."},{"fix":"Use named import: import { AmplifyLogger } from '@aws-amplify/amplify-cli-logger'; instead of default import.","cause":"Default import results in undefined because the package only exports named exports.","error":"TypeError: Cannot read properties of undefined (reading 'info')"},{"fix":"Use LogLevel instead: import { LogLevel } from '@aws-amplify/amplify-cli-logger';","cause":"Incorrect enum name: 'LogLevels' instead of 'LogLevel'.","error":"TS2339: Property 'LogLevels' does not exist on type 'typeof import(\"@aws-amplify/amplify-cli-logger\")'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}