<commit_before>/* jslint node: true */
'use strict';

/*
* @name /lib/tapestry-logger-loggly.js
* @description A Tapestry logger module to send logs to Loggly
* @since Wed Feb 12 2014
* @author <NAME> <<EMAIL>>
*/

( function() {

	var https = require( 'https' );

	/**
	* Constructor for a Loggly object
	* @param {Object} connectionOptions, proxies whatever is passed in to Tapestry as the logger.connection
	*/
	var loggly = function( connectionOptions ) {
		this.connection = connectionOptions;
	};

	exports = module.exports = loggly;

	/**
	* Push to Loggly the passed value
	* @param {Object} options:
	* - service, tell Loggly who this log is from, probably the name of your app/module
	* - type, payload? error? system log?
	* - namespace, which of the services "buckets" should we throw this in?
	* @param {Object} log, the object to push to Loggly
	*/
	loggly.prototype.log = function( options, log ) {

		var self = this;
		// if we have stuff...
		if( options.service && options.type && options.namespace && log ) {
			// the options make up our tags to Loggly
			var httpsOptions = {
				hostname: self.connection.host,
				port: 443,
				path: '/' + self.connection.path + '/' + self.connection.key + '/tag/' + options.service + ',' + options.type + ',' + options.namespace,
				method: 'POST'
			};
			var request = https.request( httpsOptions );
			// add the namespace to the log
			log.namespace = options.namespace;
			// ensure the log is a string
			if( typeof log !== 'string' ) {
				log = JSON.stringify( log );
			}
			// write data to request body
			request.write( log );
			request.end();
		}

	};

} )();<commit_msg>move request instantiation further down<commit_after>/* jslint node: true */
'use strict';

/*
* @name /lib/tapestry-logger-loggly.js
* @description A Tapestry logger module to send logs to Loggly
* @since Wed Feb 12 2014
* @author <NAME> <<EMAIL>>
*/

( function() {

	var https = require( 'https' );

	/**
	* Constructor for a Loggly object
	* @param {Object} connectionOptions, proxies whatever is passed in to Tapestry as the logger.connection
	*/
	var loggly = function( connectionOptions ) {
		this.connection = connectionOptions;
	};

	exports = module.exports = loggly;

	/**
	* Push to Loggly the passed value
	* @param {Object} options:
	* - service, tell Loggly who this log is from, probably the name of your app/module
	* - type, payload? error? system log?
	* - namespace, which of the services "buckets" should we throw this in?
	* @param {Object} log, the object to push to Loggly
	*/
	loggly.prototype.log = function( options, log ) {

		var self = this;
		// if we have stuff...
		if( options.service && options.type && options.namespace && log ) {
			// the options make up our tags to Loggly
			var httpsOptions = {
				hostname: self.connection.host,
				port: 443,
				path: '/' + self.connection.path + '/' + self.connection.key + '/tag/' + options.service + ',' + options.type + ',' + options.namespace,
				method: 'POST'
			};
			// add the namespace to the log
			log.namespace = options.namespace;
			// ensure the log is a string
			if( typeof log !== 'string' ) {
				log = JSON.stringify( log );
			}
			var request = https.request( httpsOptions );
			// write data to request body
			request.write( log );
			request.end();
		}

	};

} )();
{'fraction_non_alphanumeric': 0.13381555153707053, 'fraction_numerical': 0.0054249547920434, 'mean_word_length': 3.082410824108241, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '623270', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1017, 'n_words': 360}