How to use the @awesomeeng/awesome-log.init function in @awesomeeng/awesome-log

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-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.

@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 1 year ago

Package Health Score

49 / 100
Full package analysis