How to use the @aws-amplify/core.ConsoleLogger function in @aws-amplify/core

To help you get started, we’ve selected a few @aws-amplify/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / storage / src / index.ts View on Github external
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

import StorageClass from './Storage';
import { StorageProvider } from './types';

import Amplify, { ConsoleLogger as Logger } from '@aws-amplify/core';

const logger = new Logger('Storage');

let _instance: StorageClass = null;

if (!_instance) {
    logger.debug('Create Storage Instance');
    _instance = new StorageClass();
    _instance.vault = new StorageClass();
    
    const old_configure = _instance.configure;
    _instance.configure = (options) => {
        logger.debug('storage configure called');
        const vaultConfig = {...old_configure.call(_instance, options)};

        // set level private for each provider for the vault
        Object.keys(vaultConfig).forEach((providerName) => {
            if (typeof vaultConfig[providerName] !== 'string') {
github aws-amplify / amplify-js / packages / analytics / src / trackers / SessionTracker.ts View on Github external
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

// the session tracker for web

import { ConsoleLogger as Logger, Hub, JS, Constants } from '@aws-amplify/core';
import { SessionTrackOpts } from '../types';

const logger = new Logger('SessionTracker');

const defaultOpts: SessionTrackOpts = {
	enable: false,
	provider: 'AWSPinpoint',
};

let initialEventSent = false;

export default class SessionTracker {
	private _tracker;
	private _hasEnabled;
	private _config: SessionTrackOpts;

	private _hidden;
	private _visibilityChange;
github aws-amplify / amplify-js / packages / api / src / API.ts View on Github external
*
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */
import { OperationDefinitionNode, GraphQLError } from 'graphql';
import { print } from 'graphql/language/printer';
import { parse } from 'graphql/language/parser';
import * as Observable from 'zen-observable';
import { RestClient as RestClass } from './RestClient';
import Amplify, { ConsoleLogger as Logger, Credentials } from '@aws-amplify/core';
import { GraphQLOptions, GraphQLResult } from './types';
import Cache from '@aws-amplify/cache';
import { v4 as uuid } from 'uuid';

const logger = new Logger('API');

export const graphqlOperation = (query, variables = {}) => ({ query, variables });

/**
 * Export Cloud Logic APIs
 */
export default class APIClass {
    /**
     * @private
     */
    private _options;
    private _api = null;
    private _pubSub = Amplify.PubSub;

    /**
     * Initialize Storage with AWS configuration
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Widget / TextPicker.tsx View on Github external
*/

import * as React from 'react';
import { Component } from 'react';

import { ConsoleLogger as Logger } from '@aws-amplify/core';
import AmplifyTheme from '../AmplifyTheme';
import Picker from './Picker';

const Container = {};

const PickerPreview = {
	maxWidth: '100%',
};

const logger = new Logger('TextPicker');

export interface ITextPickerProps {
	onLoad?: (dataUrl: any) => void;
	onPick?: (data: any) => void;
	preview?: 'hidden';
	previewText?: string;
	theme?: any;
	title?: string;
}

export interface ITextPickerState {
	previewText: string;
}

export default class TextPicker extends Component<
	ITextPickerProps,
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withFacebook.tsx View on Github external
*/

import * as React from 'react';

import { I18n, ConsoleLogger as Logger } from '@aws-amplify/core';
import Auth from '@aws-amplify/auth';
import AmplifyTheme from '../../Amplify-UI/Amplify-UI-Theme';
import { facebookSignInButton } from '@aws-amplify/ui';
import {
	SignInButton,
	SignInButtonIcon,
	SignInButtonContent,
} from '../../Amplify-UI/Amplify-UI-Components-React';
import Constants from '../common/constants';

const logger = new Logger('withFacebook');

export default function withFacebook(Comp) {
	return class extends React.Component {
		constructor(props: any) {
			super(props);

			this.fbAsyncInit = this.fbAsyncInit.bind(this);
			this.initFB = this.initFB.bind(this);
			this.signIn = this.signIn.bind(this);
			this.signOut = this.signOut.bind(this);
			this.federatedSignIn = this.federatedSignIn.bind(this);

			this.state = {};
		}

		signIn() {
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / SignIn.jsx View on Github external
import {
    FormSection,
    FormField,
    SectionHeader,
    SectionBody,
    SectionFooter,
    Button,
    Link,
    Hint,
    Input,
    InputLabel,
    SectionFooterPrimaryContent,
    SectionFooterSecondaryContent,
} from '../Amplify-UI/Amplify-UI-Components-React';

const logger = new Logger('SignIn');

export default class SignIn extends AuthPiece {
    constructor(props) {
        super(props);

        this.checkContact = this.checkContact.bind(this);
        this.signIn = this.signIn.bind(this);
        this.onKeyDown = this.onKeyDown.bind(this);

        this._validAuthStates = ['signIn', 'signedOut', 'signedUp'];
        this.state = {};
    }

    componentDidMount() {
        window.addEventListener('keydown', this.onKeyDown);
    }
github aws-amplify / amplify-js / packages / predictions / src / index.ts View on Github external
*     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */
import PredictionsClass from './Predictions';

import Amplify, { ConsoleLogger as Logger } from '@aws-amplify/core';
import {
    AmazonAIConvertPredictionsProvider, AmazonAIIdentifyPredictionsProvider,
    AmazonAIPredictionsProvider, AmazonAIInterpretPredictionsProvider,
} from './Providers';

import { InterpretTextCategories } from './types';
const logger = new Logger('PubSub');

let _instance: PredictionsClass = null;

if (!_instance) {
    logger.debug('Create Predictions Instance');
    _instance = new PredictionsClass({});
}

const Predictions = _instance;
Amplify.register(Predictions);

export default Predictions;
export {
    AmazonAIIdentifyPredictionsProvider, AmazonAIConvertPredictionsProvider,
    AmazonAIPredictionsProvider, AmazonAIInterpretPredictionsProvider, InterpretTextCategories
};
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / SignIn.tsx View on Github external
FormField,
    SectionHeader,
    SectionBody,
    SectionFooter,
    Button,
    Link,
    Hint,
    Input,
    InputLabel,
    SectionFooterPrimaryContent,
    SectionFooterSecondaryContent
} from '../Amplify-UI/Amplify-UI-Components-React';

import { auth } from '../Amplify-UI/data-test-attributes';

const logger = new Logger('SignIn');

export interface ISignInProps extends IAuthPieceProps {
    federated?: any;
    override?: any;
}

export interface ISignInState extends IAuthPieceState {
    loading?: boolean;
}

export default class SignIn extends AuthPiece {
    constructor(props: ISignInProps) {
        super(props);

        this.checkContact = this.checkContact.bind(this);
        this.signIn = this.signIn.bind(this);
github aws-amplify / amplify-js / packages / predictions / src / Providers / AmazonAIConvertPredictionsProvider.ts View on Github external
import { AbstractConvertPredictionsProvider } from "../types/Providers/AbstractConvertPredictionsProvider";
import * as Translate from 'aws-sdk/clients/translate';
import * as TextToSpeech from 'aws-sdk/clients/polly';
import {
    TranslateTextInput, TextToSpeechInput,
    SpeechToTextInput, TranslateTextOutput, TextToSpeechOutput,
    SpeechToTextOutput, isBytesSource} from "../types";
import { Credentials, ConsoleLogger as Logger, Signer } from '@aws-amplify/core';
import { EventStreamMarshaller, MessageHeaderValue } from '@aws-sdk/eventstream-marshaller';
import { fromUtf8, toUtf8 } from '@aws-sdk/util-utf8-node';

const logger = new Logger('AmazonAIConvertPredictionsProvider');
const eventBuilder = new EventStreamMarshaller(toUtf8, fromUtf8);

export default class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictionsProvider {

    private translate: Translate;
    private textToSpeech: TextToSpeech;
    constructor() {
        super();
    }

    getProviderName() {
        return "AmazonAIConvertPredictionsProvider";
    }

    protected translateText(input: TranslateTextInput): Promise {
        logger.debug("Starting translation");
github aws-amplify / amplify-js / packages / analytics / src / trackers / EventTracker.ts View on Github external
*
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

import { delegate } from '../vendor/dom-utils';
import { EventTrackOpts } from '../types';
import { ConsoleLogger as Logger, JS } from '@aws-amplify/core';

const logger = new Logger('EventTracker');

const defaultOpts: EventTrackOpts = {
	enable: false,
	events: ['click'],
	selectorPrefix: 'data-amplify-analytics-',
	provider: 'AWSPinpoint',
};

export default class EventTracker {
	private _tracker;
	private _config: EventTrackOpts;
	private _delegates;

	constructor(tracker, opts) {
		if (!JS.browserOrNode().isBrowser || !window.addEventListener) {
			logger.debug('not in the supported web environment');