How to use the forest-express.logger function in forest-express

To help you get started, we’ve selected a few forest-express 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 ForestAdmin / forest-express-sequelize / src / services / search-builder.js View on Github external
//         searchFields.
    const fieldsSimpleNotFound = _.xor(
      searchFields,
      _.map(fields, (field) => field.field),
    );
    const fieldsAssociationNotFound = _.xor(
      _.map(searchAssociationFields, (association) => association.split('.')[0]),
      _.keys(associations),
    );

    if (fieldsSimpleNotFound.length) {
      Interface.logger.warn(`Cannot find the fields [${fieldsSimpleNotFound}] while searching records in model ${model.name}.`);
    }

    if (fieldsAssociationNotFound.length) {
      Interface.logger.warn(`Cannot find the associations [${fieldsAssociationNotFound}] while searching records in model ${model.name}.`);
    }
  }
github ForestAdmin / forest-express-mongoose / src / services / search-builder.js View on Github external
const promise = new Promise(async (resolve) => {
          try {
            const condition = await Promise.resolve(field.search(params.search));
            if (condition) {
              pushCondition(condition, field.field);
            }
            this.hasSmartFieldSearch = true;
          } catch (error) {
            Interface.logger.error(`Cannot search properly on Smart Field ${field.field}`, error);
          }

          resolve();
        });
        promises.push(promise);
github ForestAdmin / forest-express-mongoose / src / services / resource-updater.js View on Github external
.catch((error) => {
        if (error.message.indexOf('Cast to') > -1 && error.message.indexOf('failed for value') > -1) {
          Interface.logger.warn(`Cannot update the ${modelName} #${recordId} because of a "type" key usage (which is a reserved keyword in Mongoose).`);
        } else {
          Interface.logger.error(`Cannot update the ${modelName} #${recordId} because of an unexpected issue: ${error}`);
        }

        return model.findByIdAndUpdate(recordId);
      });
}
github ForestAdmin / forest-express-sequelize / src / adapters / sequelize.js View on Github external
.each(_.values(model.associations), (association) => {
      try {
        const schema = getSchemaForAssociation(association);
        fields.push(schema);
      } catch (error) {
        Interface.logger.error(`Cannot fetch properly association ${association.associationAccessor} of model ${model.name}`, error);
      }
    });
github ForestAdmin / forest-express-mongoose / src / adapters / mongoose.js View on Github external
function formatRef(ref) {
    const models = mongooseUtils.getModels(opts);
    if (models[ref]) {
      return utils.getModelName(models[ref]);
    }
    Interface.logger.warn(`Cannot find the reference "${ref}" on the model "${model.modelName}".`);
    return null;
  }