How to use the @nestjs/common.Logger.log function in @nestjs/common

To help you get started, weโ€™ve selected a few @nestjs/common 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 TimurRK / nestjs-example / src / common / logger / logger.service.ts View on Github external
public log(message: any, context?: string) {
    if (this.isValidLevel(ELogLevel.debug)) {
      Logger.log(JSON.stringify(message, null, 2), context || this._context);
    }
  }
  // tslint:disable-next-line: no-any
github qas / examples-nodejs-cqrs-es-swagger / src / users / events / handlers / user-deleted.handler.ts View on Github external
handle(event: UserDeletedEvent) {
    Logger.log(event, 'UserDeletedEvent'); // write here
  }
}
github qas / examples-nodejs-cqrs-es-swagger / src / users / commands / handlers / delete-user.handler.ts View on Github external
async execute(command: DeleteUserCommand, resolve: (value?) => void) {
    Logger.log('Async DeleteUserHandler...', 'DeleteUserCommand');
    const {userDto} = command;
    const user = this.publisher.mergeObjectContext(
      await this.repository.deleteUser(userDto),
    );
    user.commit();
    resolve();
  }
}
github nitro-stack / nitro-cats / server / src / cat / cat.controller.ts View on Github external
uploadCat(
    @UploadedFile()
    file: UploadedFileMetadata,
  ) {
    Logger.log(
      `File "${file.originalname}" was uploaded using Azure Storage Interceptor`,
      'CatController',
    );

    return this.addCat(file.storageUrl);
  }
github ahmetuysal / nest-hackathon-starter / src / auth / auth.service.ts View on Github external
async changeEmail(token: string): Promise {
    const emailChange = await this.emailChangeRepository.findOne(token);
    if (emailChange && emailChange.validUntil > new Date()) {
      const userEntity = await this.userService.getUserEntityById(
        emailChange.userId,
      );
      userEntity.email = emailChange.newEmail;
      await this.userService.updateUser(userEntity);
      await this.emailChangeRepository.delete(emailChange);
    } else {
      Logger.log(`Invalid email change token ${token} is rejected.`);
      throw new NotFoundException();
    }
  }
github juicycleff / ultimate-backend / apps / service-auth / src / auth / auth.service.ts View on Github external
public async validateUser(input: LoginInput): Promise {
    try {
      return await this.loginCmd(input);
    } catch (e) {
      Logger.log(e, 'ValidateUser');
      throw new AuthenticationError(e.message);
    }
  }
}
github juicycleff / ultimate-backend / libs / core / src / cqrs / events / handlers / auth / user-loggedin.handler.ts View on Github external
handle(event: UserLoggedInEvent): any {
    Logger.log(event, 'UserLoggedInHandler');
  }
}
github rucken / cli / new / src / libs / auth / services / auth.service.ts View on Github external
async facebookSignIn(code: string, host?: string): Promise {
    const queryParams: string[] = [
      `client_id=${this.fbConfig.client_id}`,
      `redirect_uri=${this.fbConfig.oauth_redirect_uri}`,
      `client_secret=${this.fbConfig.client_secret}`,
      `code=${code}`
    ];
    const uri: string = `${this.fbConfig.access_token_uri}?${queryParams.join(
      '&'
    )}`.replace('{host}', host);
    Logger.log(uri, AuthService.name + ':facebookSignIn');
    try {
      const response = await this.httpService
        .get(uri)
        .pipe(map(res => res.data))
        .toPromise();
      if (response.error) {
        Logger.error(JSON.stringify(response), undefined, AuthService.name);
        throw new BadRequestException(response.error.message);
      }
      const access_token = response.access_token;
      const uriToken = `${this.localUri}/api/auth/facebook/token`;
      const profileResponse = await this.httpService
        .post(uriToken, stringify({ access_token }), {
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        })
        .pipe(map(res => res.data))
github ZhiXiao-Lin / nestify / packages / config / src / config.module.ts View on Github external
static initEnvironment(rootPath: string, env: string = process.env.NODE_ENV || 'development') {
        const envPath = path.resolve(rootPath, !env ? '.env' : `.env.${env}`);
        dotenv({ path: envPath });

        Logger.log(`Loading environment variables from ${envPath}`, ConfigModule.name);
    }