Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 912 Bytes

logger_guide.md

File metadata and controls

59 lines (42 loc) · 912 Bytes

Logger

AWS Amplify writes logs through Logger.

Usage

Create a logger

import { Logger } from 'aws-amplify';

const logger = new Logger('foo');

logger.info('info bar');
logger.debug('debug bar');
logger.warn('warn bar');
logger.error('error bar');

When error

try {
    ...
} catch(e) {
    logger.error('error happened', e);
}

Log Level

Log level can be set on logger creation

const logger = new Logger('foo', 'INFO');

logger.debug('callback data', data); // this will not write, unless ...

Global setting overrides logger instance setting

Amplify.Logger.LOG_LEVEL = 'DEBUG';

const logger = new Logger('foo', 'INFO');

logger.debug('callback data', data); // this will write

During web development, you can set global log level in browser console log

window.LOG_LEVEL = 'DEBUG';

Supported log levels:

  • ERROR
  • WARN
  • INFO
  • DEBUG
  • VERBOSE