How to use the log4js.addLogger function in log4js

To help you get started, we’ve selected a few log4js 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 openmrs / openmrs-contrib-id / app / routes / profile / email.js View on Github external
'use strict';
/**
 * This file handles all user-email request
 */
const path = require('path');
const async = require('async');
const _ = require('lodash');

const common = require('../../common');
const conf = require('../../conf');
const verification = require('../../email-verification');
const log = require('log4js').addLogger('express');
const mid = require('../../express-middleware');
const User = require('../../models/user');
const utils = require('../../utils');
const validate = require('../../validate');


exports = module.exports = app => {


  app.get('/profile/email/verify/:id', (req, res, next) => {
    // check for valid email verification ID

    let newEmail = '';
    let newUser = {};
    const id = utils.urlDecode64(req.params.id);
github openmrs / openmrs-contrib-id / app / ldap.js View on Github external
* Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */

const ldap = require('ldapjs');
const async = require('async');
const _ = require('lodash');
const log = require('log4js').addLogger('ldap');

const conf = require('./conf');
const serverAttr = conf.ldap.server;
const userAttr = conf.ldap.user;
const groupAttr = conf.ldap.group;


// ldap connection url
const url = serverAttr.uri;

const systemDN = `${serverAttr.rdn}=${serverAttr.loginUser},${serverAttr.baseDn}`;
const bindCredentials = serverAttr.password;

// LDAP client used for general operation
const client = ldap.createClient({
  url: url,
github openmrs / openmrs-contrib-id / app / routes / profile / password.js View on Github external
'use strict';
/**
 * This file handles users' password related request.
 */
var path = require('path');
var async = require('async');
var _ = require('lodash');

var common = require('../../common');
var conf = require('../../conf');
var verification = require('../../email-verification');
var validate = require('../../validate');
var log = require('log4js').addLogger('express');
var mid = require('../../express-middleware');
var User = require('../../models/user');



var profileMid = require('./middleware');

exports = module.exports = function (app) {


/// Deprecated
app.post('/password', mid.forceLogin, profileMid.passwordValidator,
  function(req, res, next) {

  var updUser = req.session.user;
github openmrs / openmrs-contrib-id / app / routes / auth / logout.js View on Github external
'use strict';
/**
 * This is the logout logic for Dashboard
 */
const log = require('log4js').addLogger('express');

exports = module.exports = app => {


  app.get('/logout', (req, res) => res.redirect('/disconnect'));

  app.get('/disconnect', (req, res, next) => {
    if (req.session.user) {
      log.info(`${req.session.user.username}: disconnecting`);
      req.session.destroy();
    }
    // redirect to a predefined destination or to home
    const destination = req.query.destination;
    if (destination) {
      res.redirect(decodeURIComponent(destination));
    } else {
github openmrs / openmrs-contrib-id / app / routes / reset-password / index.js View on Github external
'use strict';
/**
 * This file handles the password-reset functionalities
 */

const path = require('path');
const async = require('async');
const _ = require('lodash');

const conf = require('../../conf');
const mid = require('../../express-middleware');
const validate = require('../../validate');
const verification = require('../../email-verification');
const utils = require('../../utils');
const log = require('log4js').addLogger('express');

const User = require('../../models/user');

exports = module.exports = app => {


  app.get('/reset', mid.forceLogout, (req, res, next) => {
    res.render('views/reset-public');
  });

  app.post('/reset', mid.forceLogout, (req, res, next) => {
    // case-insensitive
    const resetCredential = req.body.resetCredential.toLowerCase();
    const USER_NOT_FOUND_MSG = 'User data not found';
    const REQUIRED = 'Username or e-mail address is required to continue.';
github openmrs / openmrs-contrib-id / app / email-verification.js View on Github external
'use strict';
const crypto = require('crypto');
const nodemailer = require('nodemailer');
const fs = require('fs');
const path = require('path');
const pug = require('pug');
const url = require('url');
const async = require('async');
const _ = require('lodash');
const uuid = require('uuid');
const utils = require('./utils');

const conf = require('./conf');
const log = require('log4js').addLogger('email-verification');

const EmailVerification = require('./models/email-verification');

// update nodemailer
const transporter = nodemailer.createTransport(conf.email.smtp);

const simpleCallback = err => {
  if (err) {
    log.error(err);
  }
};

// create a verification and send emails
/* begin({
 *   addr,          (required) string of email address to send to
 *   subject,       (required) subject of email sent
github openmrs / openmrs-contrib-id / app / db-admin / syncAdminUsers.js View on Github external
'use strict';
const async = require('async');
const q = require('q');
const log = require('log4js').addLogger('db-admin');
const formage = require('formage');
const utils = require('../utils');
const _ = require('lodash');

/**
 * Mongoose models. Will be assigned when init() is called.
 */
let FormageUser;
let User;

/**
 * Create or update a Formage user that corresponds to this Dashboard admin.
 * @param  {User}     user     ID Dashboard user document
 * @param  {Function} callback Optional callback that receives error and create
 *                             Formage user
 * @return {Promise}           Promise resolved after Formage user is saved
github openmrs / openmrs-contrib-id / app / routes / profile / profile.js View on Github external
'use strict';
/**
 * This is the router for /profile. It displays a users profile,
 * and hanldes its editing.
 */
const path = require('path');
const async = require('async');
const _ = require('lodash');
const log = require('log4js').addLogger('express');


const common = require('../../common');
const conf = require('../../conf');
const verification = require('../../email-verification');
const validate = require('../../validate');
const mid = require('../../express-middleware');
const User = require('../../models/user');
const utils = require('../../utils');

exports = module.exports = app => {


  app.get('/profile', mid.forceLogin,
    (req, res, next) => {
github openmrs / openmrs-contrib-id / app / user-modules / openmrs-contrib-id-sso / lib / discourse.js View on Github external
'use strict';
const discourse_sso = require('discourse-sso');
const path = require('path');
const url = require('url');
const request = require('request');
const sso = require('./sso');
const User = require('../../../models/user');
const log = require('log4js').addLogger('discourse-sso');

const conf = sso.conf.strategies.discourse;
const discourse = new discourse_sso(conf.secret);

exports = module.exports = app => {


	const buildURL = (payload, sig, user) => {
		if (!discourse.validate(payload, sig)) {
			return false;
		}
		const nonce = discourse.getNonce(payload);

		const userparams = {
			'nonce': nonce,
			'external_id': user.username,
github openmrs / openmrs-contrib-id / app / routes / auth / login.js View on Github external
* This is the login logic for Dashboard
 */
const url = require('url');
const path = require('path');
const async = require('async');
const _ = require('lodash');


const common = require('../../common');
const conf = require('../../conf');
const verification = require('../../email-verification');
const validate = require('../../validate');
const mid = require('../../express-middleware');
const utils = require('../../utils');

const log = require('log4js').addLogger('express');

const User = require('../../models/user');

exports = module.exports = app => {


  app.get('/login', mid.forceLogout,
    (req, res, next) => {
      res.render('views/login');
    }
  );

  app.post('/login', mid.stripNewlines, (req, res, next) => {
    const username = req.body.loginusername || '';
    const password = req.body.loginpassword || '';
    const redirect = req.body.destination || '/';