How to use the @reactioncommerce/logger.debug function in @reactioncommerce/logger

To help you get started, we’ve selected a few @reactioncommerce/logger 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 reactioncommerce / reaction / imports / plugins / included / search-mongo / server / methods / searchcollections.js View on Github external
export function buildAccountSearchRecord(accountId, updatedFields) {
  Logger.debug("building account search record");
  check(accountId, String);
  check(updatedFields, Array);

  const account = Accounts.findOne(accountId);
  // let's ignore anonymous accounts
  if (account && account.emails && account.emails.length) {
    const accountSearch = {};

    // Not all required fields are used in search
    // We need to filter through fields that are used,
    // and only update the search index if one of those fields were updated
    // forceIndex is included to forceIndexing on startup, or when manually added
    const searchableFields = ["forceIndex", "shopId", "emails", "firstName", "lastName", "phone"];

    const shouldRunIndex = updatedFields && updatedFields.some((field) => searchableFields.includes(field));
github reactioncommerce / reaction / imports / plugins / core / core / server / startup / load-data.js View on Github external
export default function loadData() {
  if (!process.env.SKIP_FIXTURES) {
    /**
     * Hook to setup core additional imports during Reaction init (shops process first)
     */
    Logger.info("Load default data from /private/data/");

    let shopId = Reaction.getShopId();
    // Since import overwrites, only import Shops when none exist
    if (!shopId) {
      try {
        Logger.debug("Loading Shop Data");
        Importer.process(Assets.getText("data/Shops.json"), ["name"], Importer.shop, [shopId]);
        // ensure Shops are loaded first.
        Importer.flush(Shops);
      } catch (error) {
        Logger.error(error, "Bypassing loading Shop default data");
      }

      shopId = Reaction.getShopId();
      // make sure the default shop has been created before going further
      while (!shopId) {
        Logger.debug("Loading default shop, waiting until it's ready before moving on...");
        Meteor._sleepForMs(1000);
        shopId = Reaction.getShopId();
      }
    }
github reactioncommerce / reaction / imports / plugins / core / hydra-oauth / server / oauthEndpoints.js View on Github external
.then(async (getLoginRequestRes) => {
      const requestUrl = url.parse(getLoginRequestRes.request_url, true);
      const { loginAction } = requestUrl.query;
      // If Hydra was already able to authenticate the user, skip will be true
      // we do not need to re-authenticate the user.
      if (getLoginRequestRes.skip) {
        const acceptLoginResponse = await hydra.acceptLoginRequest(challenge, {
          subject: getLoginRequestRes.subject
        });
        Logger.debug(`Auth status confirmed from Hydra. Redirecting to: ${acceptLoginResponse.redirect_to}`);
        res.writeHead(301, { Location: acceptLoginResponse.redirect_to });
        return res.end();
      }

      res.writeHead(301, { Location: `/account/login?action=${loginAction}&login_challenge=${challenge}` });
      Logger.debug("Redirecting to Login Form for user login");
      return res.end();
    })
    .catch((errorMessage) => errorHandler(errorMessage, res));
github reactioncommerce / reaction / src / plugins / job-queue / startup.js View on Github external
Jobs.startJobServer(() => {
    Logger.debug("Background job system started");
    appEvents.emit("jobServerStart");
  });
}
github reactioncommerce / reaction / imports / plugins / included / email-smtp / server / no-meteor / util / sendSMTPEmail.js View on Github external
export default async function sendSMTPEmail(context, { job, sendEmailCompleted, sendEmailFailed }) {
  const { to, shopId, ...otherEmailFields } = job.data;

  const config = await getMailConfig(context, shopId);
  if (config.direct) {
    sendEmailFailed(job, "SMTP mail settings not configured");
    return;
  }

  Logger.debug(config, "Sending SMTP email with config");

  const transport = nodemailer.createTransport(config);

  transport.sendMail({ to, shopId, ...otherEmailFields }, (error) => {
    if (error) {
      sendEmailFailed(job, `Email job failed: ${error.toString()}`);
    } else {
      sendEmailCompleted(job, `Successfully sent email to ${to}`);
    }
  });
}
github reactioncommerce / reaction / src / plugins / email-smtp / util / sendSMTPEmail.js View on Github external
export default async function sendSMTPEmail(context, { job, sendEmailCompleted, sendEmailFailed }) {
  const { to, shopId, ...otherEmailFields } = job.data;

  const config = await getMailConfig(context, shopId);
  if (config.direct) {
    sendEmailFailed(job, "SMTP mail settings not configured");
    return;
  }

  Logger.debug(config, "Sending SMTP email with config");

  const transport = nodemailer.createTransport(config);

  transport.sendMail({ to, shopId, ...otherEmailFields }, (error) => {
    if (error) {
      sendEmailFailed(job, `Email job failed: ${error.toString()}`);
    } else {
      sendEmailCompleted(job, `Successfully sent email to ${to}`);
    }
  });
}
github reactioncommerce / reaction / imports / node-app / plugins / job-queue / shutdown.js View on Github external
Jobs.shutdownJobServer(() => {
        Logger.debug("Background job system stopped");
        resolve();
      });
    } catch (error) {
github reactioncommerce / reaction / imports / plugins / included / search-mongo / server / jobs / buildSearchCollections.js View on Github external
const orderSearchCount = OrderSearch.find({}).count();
  const orderCount = Orders.find({}).count();
  if (!orderSearchCount && orderCount) {
    Logger.debug("No OrderSearch records found. Adding build OrderSearch Collection to jobs");
    new Job(Jobs, "order/buildSearchCollection", {})
      .priority("normal")
      .retry({
        retries: 5,
        wait: 60000,
        backoff: "exponential"
      })
      .save({
        cancelRepeats: true
      });
  } else {
    Logger.debug("OrderSearch collection already exists (or no orders), not building");
  }
}
github reactioncommerce / reaction / imports / node-app / plugins / shipping-rates / getFulfillmentMethodsWithQuotes.js View on Github external
});
    await Promise.all(awaitedShippingRateDocs);
  }

  if (rates.length === initialNumOfRates) {
    const errorDetails = {
      requestStatus: "error",
      shippingProvider: "flat-rate-shipping",
      message: "Flat rate shipping did not return any shipping methods."
    };
    rates.push(errorDetails);
    retrialTargets.push(currentMethodInfo);
    return [rates, retrialTargets];
  }

  Logger.debug("Flat rate getFulfillmentMethodsWithQuotes", rates);
  return [rates, retrialTargets];
}
github reactioncommerce / reaction / imports / plugins / included / search-mongo / server / jobs / buildSearchCollections.js View on Github external
(job, callback) => {
      Logger.debug("(re)build ProductSearch index running");
      rebuildProductSearchIndex((error) => {
        if (error) {
          job.done(error.toString(), { repeatId: true });
          callback();
        } else {
          const success = "ProductSearch Index (re)built successfully.";
          Logger.debug(success);
          job.done(success, { repeatId: true });
          callback();
        }
      });
    }
  );

@reactioncommerce/logger

Reaction application logging based on Bunyan logger

MIT
Latest version published 3 years ago

Package Health Score

36 / 100
Full package analysis

Similar packages