How to use @awesomeeng/awesome-log - 10 common examples

To help you get started, we’ve selected a few @awesomeeng/awesome-log 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 awesomeeng / awesome-log / examples / ExampleCustomWriter / ExampleCustomWriter.js View on Github external
// configuration property to enable it.
Log.init({
	writers: [{
		name: "my-writer",
		type: "my-example-writer"
	}]
});

// Then everything is exactly the same as basic usage.
//
// Start the log...
Log.start();

// Log something out to it...
// See the MyExampleCustomWriter.js file for implementation details.
Log.info("This is an example log message.");

// stop when we are done.
Log.stop();
github awesomeeng / awesome-server / examples / BasicServer / Server.js View on Github external
// (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

"use strict";

const Log = require("@awesomeeng/awesome-log");
Log.init({
	buffering: true
});
Log.start();

const AwesomeServer = require("@awesomeeng/awesome-server");

let server = new AwesomeServer();
server.addHTTPServer({
	hostname: "localhost",
	port: 7080
});
server.route("*","*",(path,request)=>{
	Log.access("Request from "+request.origin+" for "+request.url.href);
});
server.route("*","/hello",(path,request,response)=>{
	return response.writeText("Hello world.");
github awesomeeng / awesome-log / examples / ExampleSubProcess / ExampleSubProcess.js View on Github external
// (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

"use strict";

const OS = require("os");
const CP = require("child_process");

const AwesomeUtils = require("@awesomeeng/awesome-utils");

// Setup our log
const Log = require("@awesomeeng/awesome-log");
Log.init();
Log.start();

// Create a bunch of subprocesses
const NODES = OS.cpus().length-1;
const childpath = AwesomeUtils.Module.resolve(module,"./SubProcess.js");
const children = new Array(NODES).fill(0).map(()=>{
	let child = CP.fork(childpath);
	Log.captureSubProcess(child);
	return child;
});

// stop after one 1 minute
setTimeout(async ()=>{
	children.forEach((child)=>{
		Log.releaseSubProcess(child);
		child.kill(0);
github awesomeeng / awesome-log / examples / ExampleSubProcess / SubProcess.js View on Github external
// (c) 2018, The Awesome Engineering Company, https://awesomeneg.com

"use strict";

const Log = require("@awesomeeng/awesome-log");
Log.init();
Log.start();

const FREQ = 10;

let id = 0;
let running = true;

const next = ()=>{
	if (!running) return;

	id += 1;
	let level = Log.levels[(Math.random()*Log.levels.length)|0];
	Log.log(level,"This is log message "+id);
	setTimeout(next,(Math.random()*FREQ)|0);
};
github awesomeeng / awesome-log / examples / ExampleCustomWriter / ExampleCustomWriter.js View on Github external
/*
	An example of how to implement a custom writer.
 */

"use strict";

// First we require log.
const Log = require("@awesomeeng/awesome-log");

// Second, we require the writer we want to use.
require("./MyExampleWriter");

// Then initialize, just like in basic usage. However,
// you need to pass the custom writer in to the writers
// configuration property to enable it.
Log.init({
	writers: [{
		name: "my-writer",
		type: "my-example-writer"
	}]
});

// Then everything is exactly the same as basic usage.
//
// Start the log...
Log.start();

// Log something out to it...
// See the MyExampleCustomWriter.js file for implementation details.
Log.info("This is an example log message.");

// stop when we are done.
github awesomeeng / awesome-log / examples / ExampleCustomFormatter / ExampleCustomFormatter.js View on Github external
/*
	An example of how to implement a custom formatter.
 */

"use strict";

// First we require log.
const Log = require("@awesomeeng/awesome-log");

// Second, we require the writer we want to use.
require("./MyExampleFormatter");

// Then initialize, just like in basic usage. However,
// you need to pass the formatter to each writer in to the writers
// configuration property to enable it.
Log.init({
	writers: [{
		name: "console",
		type: "default",
		levels: "*",
		formatter: "my-example-formatter",
		options: {}
	}]
});

// Then everything is exactly the same as basic usage.
//
// Start the log...
Log.start();

// Log something out to it...
// See the MyExampleCustomWriter.js file for implementation details.
github awesomeeng / awesome-log / examples / ExampleUsage / ExampleUsage.js View on Github external
/*
	An example of how to basically use AwesomeLog.
 */

"use strict";

const Log = require("@awesomeeng/awesome-log");

// First we initialize the log system.
//
// This is where we can provide logging configuration, as an argument to Log.init();
//
// If you just want the defaults, pass nothing in.
Log.init();

// Once initialized, we have to start the log system.
Log.start();

// Once the log system is started you can make log statement against the
// various log levels, by default they are access, error, warn, info, debug.
Log.info("This is an example log message.");
Log.info("Another log message with arguments.",1,2,3);
Log.info({
	text: "A log object.",
	red: "red",
	green: 25,
	blue: false
});

// stop logging once we are done.
github awesomeeng / awesome-log / examples / ExampleCustomFormatter / ExampleCustomFormatter.js View on Github external
name: "console",
		type: "default",
		levels: "*",
		formatter: "my-example-formatter",
		options: {}
	}]
});

// Then everything is exactly the same as basic usage.
//
// Start the log...
Log.start();

// Log something out to it...
// See the MyExampleCustomWriter.js file for implementation details.
Log.info("This is an example log message.");

// stop when we are done.
Log.stop();
github awesomeeng / awesome-server / src / AwesomeServer.js View on Github external
&& (!handler || route.handler===handler);
	});

	// remove them
	this[$ROUTES] = this[$ROUTES].filter((route)=>{
		return matching.indexOf(route)<0;
	});

	// cleanup child routes if any
	matching.forEach((route)=>{
		(route.children||[]).forEach((child)=>{
			_unroute.call(this,child.method,child.path,child.handler);
		});
	});

	if (matching.length>0 && this.config.informative) Log.info("Removed route "+method+" "+path.toString());

	return matching.length>0;
};
github awesomeeng / awesome-config / src / ConfigInstance.js View on Github external
root = AwesomeUtils.Object.extend(root,source.content);
		});

		// run the resulting object through our resolver.
		if (this.resolver) this.resolver.resolve(root);

		// prevent our nested children from being mutated.
		// We handle this for the nested child itself in the AwesomeConfig proxy.
		Object.keys(root).forEach((key)=>{
			AwesomeUtils.Object.deepFreeze(root[key]);
		});

		// make our configuration.
		this[$CONFIG] = root;

		Log.debug("Instance "+this.id+" initialized.");
	}

@awesomeeng/awesome-log

AwesomeLog is a Log System for enterprise nodejs applications. It provides a basic out of the box logging solution that is ready to go with zero configuration but also gives you a highly configurable logging solution that with the power to do your logging

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis