Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "mozlog in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'mozlog' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

import { StatsD } from 'hot-shots';
import mozlog from 'mozlog';

import Config from '../config';
import { createDatastore, FirestoreDatastore, InMemoryDatastore } from '../lib/db';
import { ServiceNotificationProcessor } from '../lib/notificationProcessor';
import { proxyServerInit, ServerEnvironment } from '../lib/proxy-server';
import { ClientCapabilityService } from '../lib/selfUpdatingService/clientCapabilityService';
import { ClientWebhookService } from '../lib/selfUpdatingService/clientWebhookService';
import { configureHapiSentry, configureSentry } from '../lib/sentry';
import { version } from '../lib/version';

configureSentry({ enabled: false, release: version.version });

const NODE_ENV = Config.get('env');
const logger = mozlog(Config.get('log'))('notificationProcessor');

// This is a development only server
if (NODE_ENV === 'production') {
  logger.error('workerDev', {
    message: 'NODE_ENV must not be set to production to run the dev server'
  });
  process.exit(1);
}

const firestoreConfig = Config.get('firestore');
const firestoreEnabled = firestoreConfig.enabled;
delete firestoreConfig.enabled;

let db = firestoreEnabled
  ? createDatastore(FirestoreDatastore, firestoreConfig)
  : createDatastore(InMemoryDatastore, { clientWebhooks: Config.get('clientWebhooks') });
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 * Primary entry point for running the support panel in production.
 *
 * @module
 */
import mozlog from 'mozlog';

import Config from '../config';
import { init, ServerEnvironment } from '../lib/server';

const logger = mozlog(Config.get('logging'))('supportPanel');

async function main() {
  const server = await init(
    { ...Config.getProperties(), env: Config.get('env') as ServerEnvironment },
    logger
  );

  try {
    logger.info('startup', { message: 'Starting support-panel ...' });
    await server.start();
  } catch (err) {
    logger.error('startup', { err });
    process.exit(1);
  }

  process.on('uncaughtException', err => {
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var mozlog = require('mozlog');
var config = require('../config').get('log');

mozlog.config(config);

var root = mozlog('logging');
if (root.isEnabledFor('debug')) {
  root.warn(
    '\t*** CAREFUL! Louder logs (less than INFO)' + ' may include SECRETS! ***'
  );
}

module.exports = mozlog;
#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


var url = require('url');
var mozlog = require('mozlog');
var request = require('request');

var config = require('../lib/configuration');
mozlog.config(config.get('logging'));

var logger = require('mozlog')('server.basketproxy');

// Side effect - Adds default_fxa and dev_fxa to express.logger formats
var routeLogging = require('../lib/logging/route_logging');

var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');

var CORS_ORIGIN = config.get('public_url');
var API_KEY = config.get('basket.api_key');
var API_URL = config.get('basket.api_url');
var API_TIMEOUT = config.get('basket.api_timeout');
var VERIFY_URL = config.get('oauth_url') + '/v1/verify';
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'

var mozlog = require('mozlog')

var logConfig = require('../../config').get('log')

mozlog.config(logConfig)

module.exports = mozlog
#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


var fs = require('fs');
var mozlog = require('mozlog');

var config = require('../lib/configuration');
mozlog.config(config.get('logging'));

var logger = require('mozlog')('server.main');

var express = require('express');
var bodyParser = require('body-parser');

function makeApp() {
  var violations = fs.createWriteStream('violations.txt', {flags: 'a'});
  var app = express();
  app.use(bodyParser.json());
  app.get('/index.html', function (req, res) {
    res.json({result: 'ok'});
  });
  app.post('/_/csp-violation', function (req, res) {
    logger.warn('VIOLATION REPORT');
    var data = {
#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


var url = require('url');
var mozlog = require('mozlog');

var config = require('../lib/configuration');
mozlog.config(config.get('logging'));

var logger = require('mozlog')('server.nullbasket');

var express = require('express');
var bodyParser = require('body-parser');

var API_KEY = config.get('basket.api_key');
var API_URL = config.get('basket.api_url');


// Error codes are defined in:
// https://github.com/mozilla/basket-client/blob/master/basket/errors.py
/* eslint-disable sorting/sort-object-props */
var BASKET_ERRORS = {
  NETWORK_FAILURE: 1,
  INVALID_EMAIL: 2,
AWS.config.update({
  region: 'us-east-1'
});

/** Total messages to generate before stopping.
 * @constant {number}
 * @default
 */
const MESSAGE_COUNT = 10_000;

const chance = new Chance();

const sqs = new SQS();
const queueUrl = Config.get('serviceNotificationQueueUrl');
const logger = mozlog(Config.get('log'))('generate-sqs-traffic');

// Promisify the AWS send message, the Node promisify mangled the TS signature
const sqsSendMessage = (params: SQS.SendMessageRequest): Promise =>
  new Promise((resolve, reject) => {
    sqs.sendMessage(params, (err, data) => {
      if (err) {
        reject(err);
      } else {
        resolve(data);
      }
    });
  });

/**
 * Queue a SQS message.
 *
import mozlog from 'mozlog';

import { StatsD } from 'hot-shots';
import Config from '../config';
import { createDatastore, FirestoreDatastore, InMemoryDatastore } from '../lib/db';
import { ServiceNotificationProcessor } from '../lib/notificationProcessor';
import { proxyServerInit, ServerEnvironment } from '../lib/proxy-server';
import { ClientCapabilityService } from '../lib/selfUpdatingService/clientCapabilityService';
import { ClientWebhookService } from '../lib/selfUpdatingService/clientWebhookService';
import { configureHapiSentry, configureSentry } from '../lib/sentry';
import { version } from '../lib/version';

// Initialize Sentry as early as possible
configureSentry({ dsn: Config.get('sentryDsn'), release: version.version });

const logger = mozlog(Config.get('log'))('notificationProcessor');

const firestoreConfig = Config.get('firestore');
const firestoreEnabled = firestoreConfig.enabled;
delete firestoreConfig.enabled;

const db = firestoreEnabled
  ? createDatastore(FirestoreDatastore, firestoreConfig)
  : createDatastore(InMemoryDatastore, {});

export function extractRegionFromUrl(url: string) {
  const matchResult = url.match(/(?:.*\/sqs\.)([^\.]+)/i);
  if (!matchResult || matchResult.length !== 2) {
    return undefined;
  } else {
    return matchResult[1];
  }
* Logging
   */
  logging: {
    default: {
      app: 'fxa-oauth-console',
    },
  },
});

var envConfig = path.join(__dirname, '..', 'config', conf.get('env') + '.json');
var files = (envConfig + ',' + process.env.CONFIG_FILES)
  .split(',')
  .filter(fs.existsSync);
conf.loadFile(files);

require('mozlog').config(conf.get('logging'));
process.env.NODE_ENV = conf.get('env');

conf.validate();

module.exports = conf;

Is your System Free of Underlying Vulnerabilities?
Find Out Now