
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
mii-logger.js
Advanced tools
npm i mii-logger.js --save
//
const mLogger = require('mii-logger.js');
console.line({line: true});
console.log({log: true});
console.info({info: true});
console.info2({info2: true});
console.ok({ok: true});
console.warn({warn: true});
console.error({error: true});
console.debug({debug: true});
console.nocol({nocol: true});
console.p({p: true});
console.watch({watch: true});
console.force({force: true});
console.json({json: true});
[]
console.mute(); // Mute all output
console.log(' this line will not be printed');
console.log(' this line will not be printed');
console.force(' Forced to print ');
console.log(' this line will not be printed');
console.log(' this line will not be printed');
console.unMute(); // unMute all output
[]
console.log( new Error('Automatic detected Error Object with stack-trace') );
// [12:04:04][*] : #Exception: Automatic detected Errro Object with stack-trace
// [12:04:04][*] : [1]: at Object.<anonymous> (/m-sys/prog/nodejs/mii-logger/dev.main.js:93:14)
// [12:04:04][*] : [2]: at Module._compile (internal/modules/cjs/loader.js:721:30)
// [12:04:04][*] : [3]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
// [12:04:04][*] : [4]: at Module.load (internal/modules/cjs/loader.js:620:32)
// [12:04:04][*] : [5]: at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
// [12:04:04][*] : [6]: at Function.Module._load (internal/modules/cjs/loader.js:552:3)
// [12:04:04][*] : [7]: at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
// [12:04:04][*] : [8]: at executeUserCode (internal/bootstrap/node.js:342:17)
// [12:04:04][*] : [9]: at startExecution (internal/bootstrap/node.js:276:5)
// [12:04:04][*] : [10]: at startup (internal/bootstrap/node.js:227:5)
// [12:04:04][L] :
[]
console.log( console.R(' Каждый — красный ') );
console.log( console.W(' Охотник — оранжевый ') );
console.log( console.Y(' Желает — жёлтый ') );
console.log( console.G(' Знать — зелёный ') );
console.log( console.LB(' Где — голубой ') );
console.log( console.B(' Сидит — синий ') );
console.log( console.P(' Фазан — фиолетовый ') );
console.log( console.R(' Richard — red ') );
console.log( console.W(' Of — orange ') );
console.log( console.Y(' York —yellow ') );
console.log( console.G(' Gave — green ') );
console.log( console.LB(' Battle — blue ') );
console.log( console.B(' In — indigo ') );
console.log( console.P(' Vain — violet ') );
[]
const testObject = {
name: 'Tom',
age: 123,
myArr: [0,0,0,0,0],
myObj: { A:{ B:{ C:{} } } },
};
// prints as formated json, line-by-line: (defaullt: true);
// console.json( myObject, format=true, spaces=2, lineByLine=true );
console.json( testObject ); // prints as formated json, line-by-line: (defaullt: true);
{
"name": "Tom",
"age": 123,
"myArr": [
0, 0, 0, 0, 0
],
"myObj": {
"A": {
"B": {
"C": {}
}
}
}
}
console.json( testObject, false ); // no-format
// [12:34:02][L] : {"name":"Tom","age":123,"myArr":[0,0,0,0,0],"myObj":{"A":{"B":{"C":{}}}}}
console.json( testObject, true, 2, false ); // format, 2, not-line-by-line
{
"name": "Tom",
"age": 123,
"myArr": [
0, 0, 0, 0, 0
],
"myObj": {
"A": {
"B": {
"C": {}
}
}
}
}
// HASH FILE:
const sha1 = console.hash.sha1('Hello world');
const sha256 = console.hash.sha256('Hello world');
const sha384 = console.hash.sha384('Hello world');
const sha512 = console.hash.sha512('Hello world');
const md5 = console.hash.md5('Hello world');
console.json({
sha1, sha256, sha384, sha512, md5
});
{
"sha1": "7b502c3a1f48c8609ae212cdfb639dee39673f5e",
"sha256": "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c",
"sha384": "9203b0c4439fd1e6ae5878866337b7c532acd6d9260150c80318e8ab8c27ce330189f8df94fb890df1d298ff360627e1",
"sha512": "b7f783baed8297f0db917462184ff4f08e69c2d5e5f79a942600f9725f58ce1f29c18139bf80b06c0fff2bdd34738452ecf40c488c22a7e3d80cdf6f9c1c0d47",
"md5": "3e25960a79dbc69b674cd4ec67a72c62"
}
// HASH FILE:
const sha1File = console.hash.sha1File('./src/index.js');
const sha256File = console.hash.sha256File('./src/index.js');
const sha384File = console.hash.sha384File('./src/index.js');
const sha512File = console.hash.sha512File('./src/index.js');
const md5File = console.hash.md5File('./src/index.js');
console.json({
sha1File, sha256File, sha384File, sha512File, md5File
});
{
"sha1File": "64c68f13518ae7a9d7cd0527efb0bd4f05971bd1",
"sha256File": "f713de98a0e30a8a6be1ca75dde114348cef739e98c96f1474e918312f18e737",
"sha384File": "dd9a60907ce6caa615f0ac5bf38e35c0445f1baf84feb3ce380640d3e7e48e039739a114b9a1c65987f3599f39ebbc6e",
"sha512File": "b290b58dff4aac29be4884745712b09f20e9397ca8d5367e7e2d27d1145957f7ded16b1823280571960ed2422919d8cce7e342d51bb41123b37d18b3c585c372",
"md5File": "5ce1be8a91e7cdab8f21a09e272d32e9"
}
const absPath = console.getAbsPath( './test.json' );
const file = console.readFileSync( './test.json' );
const json_t = console.jsonFromFile('./test.json');
const randInt = console.randInt( 0, 1000 );
const randFloat = console.randFloat( 0, 1000 );
const hostname = console.getHostname();
const isFile = console.isFile('./test.json');
const isDir = console.isDir('./test.json');
const listDir = console.listDir('./');
console.json({
absPath, file:'[*file-content*]', json_t, randInt, randFloat, hostname, isFile, isDir, listDir
}, true, 4);
{
"absPath": "/m-sys/prog/nodejs/mii-logger/test.json",
"file": "[*file-content*]",
"json_t": {
"name": "Tom",
"age": 123,
"PI": 3.1415,
"obj": {
"A": {
"B": {
"C": {
"D": {
"END": 777
}
}
}
}
}
},
"randInt": 302,
"randFloat": 247.4021970490431,
"hostname": "abi",
"isFile": true,
"isDir": false,
"listDir": [
".git",
".gitignore",
"README.md",
"deploy.js",
"dev",
"dev.main.js",
"git-imgs",
"mii-dev",
"node_modules",
"package-lock.json",
"package.json",
"src",
"test.file",
"test.json"
]
}
const fileInfo = console.getFileInfo( './src/index.js' );
console.json({ fileInfo });
{
"fileInfo": {
"dev": 2052,
"mode": 33188,
"nlink": 1,
"uid": 1000,
"gid": 1000,
"rdev": 0,
"blksize": 4096,
"ino": 7574841,
"size": 14233,
"blocks": 32,
"atimeMs": 1553686826588.2861,
"mtimeMs": 1553686821032.3079,
"ctimeMs": 1553686821032.3079,
"birthtimeMs": 1553686821032.3079,
"atime": "2019-03-27T11:40:26.588Z",
"mtime": "2019-03-27T11:40:21.032Z",
"ctime": "2019-03-27T11:40:21.032Z",
"birthtime": "2019-03-27T11:40:21.032Z"
}
}
[]
// READ Json
const json_t = console.jsonFromFile( 'my-file.json' );
// WRITE Json
console.jsonToFile( 'my-file.json', {myKey: 'myVal'} );
// optional
console.jsonToFile( 'my-file.json', {myKey: 'myVal'}, format=true, indent=2 );
// READ File
const file = console.readFileSync( 'my-file.txt' );
// WRITE File
console.writeFileSync( 'my-file.txt', 'some text data or json' );
// optional
console.writeFileSync( 'my-file.txt', 'some text data or json', encoding='utf-8' );
FAQs
mii-logger: Simple nodejs console logger
We found that mii-logger.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.