Comparing version 1.1.2 to 1.1.3
46
index.js
@@ -0,8 +1,20 @@ | ||
const slash = function() { | ||
if (process.platform.includes('win')) { | ||
return '\\'; | ||
} else { | ||
return '/'; | ||
} | ||
}; | ||
/** | ||
* ### Logs the given message to the console following the given format: | ||
* `{TIME} | {MODULE} | {MESSAGE}` | ||
* | ||
* **For more info on each of these and more, check the {@link https://github.com/jamesinaxx/Abbie/wiki/Reference wiki on github}** | ||
* | ||
* | ||
* @param {string} message The message you would like to log | ||
* @param {number} level The level of log message (0 = info, 1 = error, 2 = good news) | ||
*/ | ||
exports.log = function (message, level = 'info') { | ||
const chalk = require('chalk'); | ||
function log(message, level = 0) { | ||
function getName(string) { | ||
@@ -12,6 +24,11 @@ let name = string; | ||
dirs.shift(); | ||
for (const word of name.split('\\')) { | ||
for (const word of name.split(slash())) { | ||
dirs.push(word.charAt(0).toUpperCase() + word.slice(1)); | ||
} | ||
name = dirs.join('/'); | ||
name = dirs | ||
.join('/') | ||
.replace('.js', '') | ||
.replace('.ts', '') | ||
.replace('.jsx', '') | ||
.replace('.tsx', ''); | ||
@@ -22,8 +39,4 @@ return name; | ||
const type = getName( | ||
require.main.filename.replace(require('app-root-path').path + '\\', ''), | ||
) | ||
.replace('.js', '') | ||
.replace('.ts', '') | ||
.replace('.jsx', '') | ||
.replace('.tsx', ''); | ||
require.main.filename.replace(require('app-root-path').path + slash(), ''), | ||
); | ||
@@ -74,10 +87,17 @@ // #region Timestamp | ||
const chalk = require('chalk'); | ||
let lvl = ''; | ||
switch (level) { | ||
case 1: | ||
message = chalk.red(message); | ||
lvl = chalk.red('Error'); | ||
break; | ||
case 2: | ||
message = chalk.green(message); | ||
lvl = chalk.green('Good '); | ||
break; | ||
default: | ||
lvl = 'Info '; | ||
break; | ||
@@ -87,6 +107,8 @@ } | ||
console.log( | ||
`${chalk.green(time())} | ${chalk.cyanBright( | ||
`${chalk.green(time())} | ${lvl} | ${chalk.cyanBright( | ||
'[' + type + ']', | ||
)} ${message}`, | ||
); | ||
}; | ||
} | ||
module.exports.log = log; |
{ | ||
"name": "abbie", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A simple, clean, javascript logger", | ||
"main": "index.js", | ||
"types": "./types/index.d.ts", | ||
"types": "./typings/index.d.ts", | ||
"scripts": { | ||
"test": "node ./tests/test.js", | ||
"test": "npm run jstest && npm run tstest", | ||
"jstest": "node ./tests/JSTest.js", | ||
"tstest": "npx tsc && npx ts-node ./tests/TSTest.ts", | ||
"coverage": "covecov" | ||
@@ -10,0 +12,0 @@ }, |
# Abbie | ||
A simple, clean, javascript logger | ||
[![Screenshot](https://raw.githubusercontent.com/jamesinaxx/Abbie/public/assets/Screenshot.png)]() | ||
[![Build Status](https://travis-ci.com/jamesinaxx/Abbie.svg?branch=public)](https://travis-ci.com/jamesinaxx/Abbie) | ||
@@ -9,4 +11,2 @@ [![DeepScan grade](https://deepscan.io/api/teams/11350/projects/15794/branches/322083/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=11350&pid=15794&bid=322083) | ||
[![Sreenshot](./assets/Screenshot.png)](https://www.npmjs.com/package/abbie) | ||
# Usage | ||
@@ -19,10 +19,10 @@ It's literally as easy as 1, 2... Not even a 3! | ||
// Basic Javascript version | ||
const logger = require('abbie'); | ||
const abbie = require('abbie'); | ||
logger.log('Hey y'all wassup!'); | ||
logger.log('Oopsie I made a booboo and this is an error', 1); | ||
logger.log('Finished Successfully!', 2); | ||
abbie.log('Hey y'all wassup!'); | ||
abbie.log('Oopsie I made a booboo and this is an error', 1); | ||
abbie.log('Finished Successfully!', 2); | ||
// Typescript version | ||
import log from 'abbie'; | ||
import { log } from 'abbie'; | ||
@@ -34,3 +34,7 @@ log('Hey y'all wassup!'); | ||
## Reference: | ||
**For a more in-depth look at calling Abbie, check out [the wiki](https://github.com/jamesinaxx/Abbie/wiki/Reference)** | ||
**Test it out on npm runkit [here](https://runkit.com/embed/g7az5h5ikphw)** | ||
## Reference | ||
``` | ||
@@ -41,1 +45,8 @@ message: 'Whatever... Literally any string', | ||
``` | ||
## Roadmap | ||
You can check out the development roadmap [here](https://github.com/jamesinaxx/Abbie/wiki/Roadmap)! | ||
### Credits | ||
* Developed by jamesinaxx | ||
* With dependencies from [inxilpro](https://www.npmjs.com/~inxilpro) (app-root-path), [qix](https://www.npmjs.com/~qix) and [sindresorhus](https://www.npmjs.com/~sindresorhus) (chalk) |
@@ -6,15 +6,8 @@ { | ||
"compilerOptions": { | ||
// Tells TypeScript to read JS files, as | ||
// normally they are ignored as source files | ||
"allowJs": true, | ||
// Generate d.ts files | ||
"declaration": true, | ||
// This compiler run should | ||
// only output d.ts files | ||
"removeComments": false, | ||
"emitDeclarationOnly": true, | ||
// Types should go into this directory. | ||
// Removing this would place the .d.ts files | ||
// next to the .js files | ||
"outDir": "types" | ||
"outDir": "typings" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8519
110
49
1