Compare commits
27 commits
v2023.02.0
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
1c396feba2 | ||
|
a7c0bee5cf | ||
5b2ebd3e90 | |||
18d07c3b64 | |||
aade8a4107 | |||
|
d56eb00801 | ||
|
d39c56761b | ||
|
24d665f2a9 | ||
|
21d7b4adff | ||
|
9494c7f1a1 | ||
|
662b7ea482 | ||
|
d7ecab02bd | ||
|
230b7062f2 | ||
|
02c0348f12 | ||
|
36a319e9e9 | ||
|
71de81ad73 | ||
ca04f1f7b2 | |||
1338067250 | |||
fe12da748a | |||
f504f4a612 | |||
da6997f0ab | |||
0defd1949b | |||
076185d889 | |||
902b8e9dce | |||
402fdb0bdd | |||
d11a129985 | |||
7ebdc84ae3 |
10 changed files with 269 additions and 181 deletions
40
.eslintrc.json
Normal file
40
.eslintrc.json
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2021
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
||||||
|
"brace-style": "off",
|
||||||
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
|
"comma-spacing": "error",
|
||||||
|
"comma-style": "error",
|
||||||
|
"curly": ["error", "multi-line", "consistent"],
|
||||||
|
"dot-location": ["error", "property"],
|
||||||
|
"handle-callback-err": "off",
|
||||||
|
"indent": ["error", "tab"],
|
||||||
|
"keyword-spacing": "error",
|
||||||
|
"max-nested-callbacks": ["error", { "max": 4 }],
|
||||||
|
"max-statements-per-line": ["error", { "max": 2 }],
|
||||||
|
"no-console": "off",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-inline-comments": "error",
|
||||||
|
"no-multi-spaces": "error",
|
||||||
|
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
||||||
|
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
||||||
|
"object-curly-spacing": ["error", "always"],
|
||||||
|
"quotes": ["error", "single"],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
"space-before-blocks": "error",
|
||||||
|
"space-infix-ops": "error",
|
||||||
|
"space-unary-ops": "error",
|
||||||
|
"spaced-comment": "error",
|
||||||
|
"yoda": "error",
|
||||||
|
"no-extra-boolean-cast": "off"
|
||||||
|
}
|
||||||
|
}
|
22
.github/workflows/npm-publish.yml
vendored
22
.github/workflows/npm-publish.yml
vendored
|
@ -1,22 +0,0 @@
|
||||||
name: Publish to NPM
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [created]
|
|
||||||
jobs:
|
|
||||||
Publish-NPM:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Setup Node
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '16.x'
|
|
||||||
registry-url: 'https://registry.npmjs.org'
|
|
||||||
scope: '@thundernetworkrad'
|
|
||||||
- name: Publish package on NPM 📦
|
|
||||||
run: npm publish --access public
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
REGISTRY1: 'registry.npmjs.org'
|
|
||||||
REGISTRY2: 'registry=https://registry.npmjs.org/'
|
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -102,3 +102,10 @@ dist
|
||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
|
# build
|
||||||
|
build
|
||||||
|
package-lock.json
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
package-lock.json
|
2
.npmrc
2
.npmrc
|
@ -1,2 +0,0 @@
|
||||||
//${REGISTRY1}/:_authToken=${NODE_AUTH_TOKEN}
|
|
||||||
${REGISTRY2}
|
|
31
CHANGELOGS.md
Normal file
31
CHANGELOGS.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Changelogs
|
||||||
|
|
||||||
|
Here are the changelogs since the first package version.
|
||||||
|
|
||||||
|
## 2023.09.03
|
||||||
|
|
||||||
|
- Cleaned up some files
|
||||||
|
|
||||||
|
## 2023.09.02
|
||||||
|
|
||||||
|
- Migrated to CHANGELOGS.md
|
||||||
|
- Now debugLevel is required and no more optional
|
||||||
|
- Added types, to choose which debug message should be logged or not
|
||||||
|
- Cleaned up some code
|
||||||
|
- Restyled README.md (also added Troubleshooting section)
|
||||||
|
- Repository moved to [Thunder Network Source](https://source.thundernetwork.org/ThunderNetworkRaD/node-cout)
|
||||||
|
- Fixed `tsc` build script in `package.json`
|
||||||
|
|
||||||
|
## 2023.07.08-2
|
||||||
|
|
||||||
|
- Fix emoji for Debug
|
||||||
|
|
||||||
|
## 2023.07.08-1
|
||||||
|
|
||||||
|
- Fix info Emoji
|
||||||
|
|
||||||
|
## 2023.07.08
|
||||||
|
|
||||||
|
- Exported the main class as default
|
||||||
|
- Add Stringify to all functions
|
||||||
|
- Changed the string type in the function to "any"
|
107
package-lock.json
generated
107
package-lock.json
generated
|
@ -1,107 +0,0 @@
|
||||||
{
|
|
||||||
"name": "node-cout",
|
|
||||||
"version": "2023.02.03",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "node-cout",
|
|
||||||
"version": "2023.02.03",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"license": "Mozilla Public License 2.0",
|
|
||||||
"dependencies": {
|
|
||||||
"@thundernetworkrad/logs": "^2023.2.3-1",
|
|
||||||
"@thundernetworkrad/time": "^2023.2.3",
|
|
||||||
"@types/node": "^18.11.18",
|
|
||||||
"tslib": "^2.5.0",
|
|
||||||
"typescript": "^4.9.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@thundernetworkrad/logs": {
|
|
||||||
"version": "2023.2.3-1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/logs/-/logs-2023.2.3-1.tgz",
|
|
||||||
"integrity": "sha512-3H+hrEThK/A8QYs92Kw8xN9WItKQjMHlf0T2yvGb7QrWhfyz3LKEHFz5j9IQWCc0LdoYIwpP4W683ZXmQqgypw==",
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@thundernetworkrad/readline-sync": "^2023.1.26-2",
|
|
||||||
"@types/node": "^18.11.18",
|
|
||||||
"tslib": "^2.5.0",
|
|
||||||
"typescript": "^4.9.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@thundernetworkrad/readline-sync": {
|
|
||||||
"version": "2023.1.30",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/readline-sync/-/readline-sync-2023.1.30.tgz",
|
|
||||||
"integrity": "sha512-vURr/jHuyum/ZRscvnkIgyIUV6VRj/ueMGGQ4tPLs8Gi4iwm4xJn2kg/Qmrnp6VdlnFDcOB3ogoMyJ0FQWkNkw==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@thundernetworkrad/time": {
|
|
||||||
"version": "2023.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/time/-/time-2023.2.3.tgz",
|
|
||||||
"integrity": "sha512-/+u+Y4I7PSuJ9sTvE7ZcNz1+2woazUwoIPMHdfXR1pMkm+A4T7sE6w1JyrdzzN4m+hpRO9azwS9G8rgv6aB9wg==",
|
|
||||||
"hasInstallScript": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/node": {
|
|
||||||
"version": "18.11.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
|
||||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
|
||||||
},
|
|
||||||
"node_modules/tslib": {
|
|
||||||
"version": "2.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
|
||||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
|
||||||
},
|
|
||||||
"node_modules/typescript": {
|
|
||||||
"version": "4.9.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
|
||||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
|
||||||
"bin": {
|
|
||||||
"tsc": "bin/tsc",
|
|
||||||
"tsserver": "bin/tsserver"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.2.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@thundernetworkrad/logs": {
|
|
||||||
"version": "2023.2.3-1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/logs/-/logs-2023.2.3-1.tgz",
|
|
||||||
"integrity": "sha512-3H+hrEThK/A8QYs92Kw8xN9WItKQjMHlf0T2yvGb7QrWhfyz3LKEHFz5j9IQWCc0LdoYIwpP4W683ZXmQqgypw==",
|
|
||||||
"requires": {
|
|
||||||
"@thundernetworkrad/readline-sync": "^2023.1.26-2",
|
|
||||||
"@types/node": "^18.11.18",
|
|
||||||
"tslib": "^2.5.0",
|
|
||||||
"typescript": "^4.9.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@thundernetworkrad/readline-sync": {
|
|
||||||
"version": "2023.1.30",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/readline-sync/-/readline-sync-2023.1.30.tgz",
|
|
||||||
"integrity": "sha512-vURr/jHuyum/ZRscvnkIgyIUV6VRj/ueMGGQ4tPLs8Gi4iwm4xJn2kg/Qmrnp6VdlnFDcOB3ogoMyJ0FQWkNkw=="
|
|
||||||
},
|
|
||||||
"@thundernetworkrad/time": {
|
|
||||||
"version": "2023.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/time/-/time-2023.2.3.tgz",
|
|
||||||
"integrity": "sha512-/+u+Y4I7PSuJ9sTvE7ZcNz1+2woazUwoIPMHdfXR1pMkm+A4T7sE6w1JyrdzzN4m+hpRO9azwS9G8rgv6aB9wg=="
|
|
||||||
},
|
|
||||||
"@types/node": {
|
|
||||||
"version": "18.11.18",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
|
||||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA=="
|
|
||||||
},
|
|
||||||
"tslib": {
|
|
||||||
"version": "2.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
|
||||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
|
||||||
},
|
|
||||||
"typescript": {
|
|
||||||
"version": "4.9.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
|
||||||
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g=="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
22
package.json
22
package.json
|
@ -1,15 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "node-cout",
|
"name": "node-cout",
|
||||||
"version": "2023.02.03",
|
"version": "2023.09.03",
|
||||||
"description": "Standard output module for JavaScript / TypeScript",
|
"description": "Standard output module for JavaScript / TypeScript",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"types": "build/index.d.ts",
|
"types": "build/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "tsc"
|
"install": "npm run build",
|
||||||
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/ThunderNetworkRaD/node-cout.git"
|
"url": "git+https://source.thundernetwork.org/ThunderNetworkRaD/node-cout.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"std",
|
"std",
|
||||||
|
@ -21,18 +23,20 @@
|
||||||
"typescript",
|
"typescript",
|
||||||
"input",
|
"input",
|
||||||
"cout",
|
"cout",
|
||||||
"await"
|
"await",
|
||||||
|
"log"
|
||||||
],
|
],
|
||||||
"author": "Thunder Network RaD | Killer Boss Original",
|
"author": "Thunder Network RaD | Killer Boss Original, Mambuco",
|
||||||
"license": "Mozilla Public License 2.0",
|
"license": "Mozilla Public License 2.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/ThunderNetworkRaD/node-cout/issues"
|
"url": "https://source.thundernetwork.org/ThunderNetworkRaD/node-cout/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/ThunderNetworkRaD/node-cout#readme",
|
"homepage": "https://source.thundernetwork.org/ThunderNetworkRaD/node-cout#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thundernetworkrad/logs": "^2023.2.3-1",
|
"@thundernetworkrad/logs": "^2023.2.5-1",
|
||||||
"@thundernetworkrad/time": "^2023.2.3",
|
"@thundernetworkrad/time": "^2023.2.5-2",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
|
"chalk": "^5.2.0",
|
||||||
"tslib": "^2.5.0",
|
"tslib": "^2.5.0",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4"
|
||||||
}
|
}
|
||||||
|
|
76
readme.md
76
readme.md
|
@ -1,15 +1,73 @@
|
||||||
# COUT
|
# node-cout
|
||||||
|
|
||||||
This module allow you to make COUT and Debugs in NodeJS
|
This package allows you to use `cout` and debug levels in Node.js.
|
||||||
|
|
||||||
Readme work in progress
|
## Installation
|
||||||
|
|
||||||
|
Run this in your project folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install node-cout
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Learn how to use `node-cout` here:
|
||||||
|
|
||||||
|
### Import
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { createCout } from '@thundernetworkrad/std';
|
import cc from 'node-cout';
|
||||||
|
|
||||||
let ccout = new createCout(0, true); // debugLevel, logs enabled (file) (like using log() )
|
const cout = new cc(1, { save: true, emoji: true, types: ['loading', 'uploading'] });
|
||||||
|
```
|
||||||
let cout = ccout.cout;
|
|
||||||
|
> You're using CommonJS and can use `require()` instead of `import`? Go on [troubleshooting](#troubleshooting).
|
||||||
cout('test', 0) // console.log day, time and the string, if the number is >= to the debugLevel
|
|
||||||
|
> Parameters:
|
||||||
|
> ```
|
||||||
|
> debugLevel: number
|
||||||
|
> options?: {
|
||||||
|
> save?: boolean
|
||||||
|
> emoji?: boolean
|
||||||
|
> types?: string[]
|
||||||
|
> }
|
||||||
|
> ```
|
||||||
|
|
||||||
|
### Logging
|
||||||
|
|
||||||
|
```js
|
||||||
|
cout.debug('Hello World', 1); // Sends a debug log (1 is debug level, if its higher than the one defined in the constructor, its not going to be logged.)
|
||||||
|
|
||||||
|
cout.info('Hello World'); // Sends an info log
|
||||||
|
|
||||||
|
cout.warn('Hello World'); // Sends a warning log
|
||||||
|
|
||||||
|
cout.error('Hello World'); // Sends an error log
|
||||||
|
|
||||||
|
cout.log('Hello World'); // Sends a normal log
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to use the `types` option, you can do it like this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
cout.debug('Hello World', 1, types);
|
||||||
|
```
|
||||||
|
|
||||||
|
`types` can either be a string or an array of strings, and if one of them matches with one of the types defined in the constructor, the log is going to be logged.
|
||||||
|
|
||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
Unfortunately, this is not supported anymore:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const cc = require('node-cout');
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to `import` the package in your CommonJS project, add this to your `package.json` file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
```
|
```
|
133
src/index.ts
133
src/index.ts
|
@ -1,36 +1,115 @@
|
||||||
let debug: number, logs1: boolean|undefined|null;
|
import { getTime } from "@thundernetworkrad/time";
|
||||||
import { getTime } from '@thundernetworkrad/time';
|
import { log } from "@thundernetworkrad/logs";
|
||||||
import { log } from '@thundernetworkrad/logs';
|
import chalk from "chalk";
|
||||||
|
|
||||||
export class createCout {
|
export default class cout {
|
||||||
/**
|
private debugLevel: number
|
||||||
* @constructor
|
private save: boolean
|
||||||
* @param debugLevel from what debug level you want to log?
|
private emoji: boolean
|
||||||
* @param logs do you want files log?
|
private types: string[]
|
||||||
*/
|
|
||||||
constructor (debugLevel: number, logs?: boolean) {
|
|
||||||
if (!debugLevel) debugLevel = 0;
|
|
||||||
if (!logs) logs = false;
|
|
||||||
debug = debugLevel;
|
|
||||||
logs1 = logs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string what to log?
|
* @param debugLevel The maximum debug level preferred
|
||||||
* @param debugLevel from what debug level this will logged?
|
* @param options.save Whetever logs are saved in a file or not
|
||||||
* @returns
|
* @param options.emoji If logs are followed by an emoji
|
||||||
|
* @param options.types Types of logs that are allowed to appear
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
cout (string: string, debugLevel?: number) {
|
constructor(debugLevel: number, options?: { save?: boolean, emoji?: boolean, types?: string[] }) {
|
||||||
if (!debugLevel) debugLevel = 0;
|
const { save, emoji, types } = options || {};
|
||||||
var time = getTime();
|
this.debugLevel = debugLevel || 0;
|
||||||
|
this.save = save || false;
|
||||||
|
this.emoji = emoji || false;
|
||||||
|
this.types = types || [];
|
||||||
|
}
|
||||||
|
|
||||||
if (debug >= debugLevel) {
|
private l(string: string, type: string) {
|
||||||
console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
let time = `${getTime().hours}:${getTime().minutes}:${getTime().seconds}`;
|
||||||
if (logs1) {
|
type = type.toUpperCase();
|
||||||
log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
|
||||||
|
if (getTime().hours < 10) time += " ";
|
||||||
|
if (getTime().minutes < 10) time += " ";
|
||||||
|
if (getTime().seconds < 10) time += " ";
|
||||||
|
|
||||||
|
let timec = chalk.blue(time), stringc: string = " ", typec: string, emoji: string, emojic: string;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "DEBUG":
|
||||||
|
stringc = chalk.grey(string);
|
||||||
|
typec = chalk.grey(type);
|
||||||
|
emoji = "📝";
|
||||||
|
emojic = "📝 ";
|
||||||
|
break;
|
||||||
|
case "LOG":
|
||||||
|
stringc = chalk.white(string);
|
||||||
|
type = " " + type;
|
||||||
|
typec = chalk.white(type);
|
||||||
|
emoji = "🪵";
|
||||||
|
emojic = "🪵 ";
|
||||||
|
break;
|
||||||
|
case "INFO":
|
||||||
|
stringc = chalk.cyan(string);
|
||||||
|
type = " " + type;
|
||||||
|
typec = chalk.cyan(type);
|
||||||
|
emoji = "ℹ️ ";
|
||||||
|
emojic = "ℹ️ ";
|
||||||
|
break;
|
||||||
|
case "WARN":
|
||||||
|
stringc = chalk.yellow(string);
|
||||||
|
type = " " + type;
|
||||||
|
typec = chalk.yellow(type);
|
||||||
|
emoji = "⚠️";
|
||||||
|
emojic = "⚠️ ";
|
||||||
|
break;
|
||||||
|
case "ERROR":
|
||||||
|
stringc = chalk.red(string);
|
||||||
|
typec = chalk.red(type);
|
||||||
|
emoji = "❌";
|
||||||
|
emojic = "❌ ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (this.save) {
|
||||||
|
string.split("\n").forEach((line) => {
|
||||||
|
log(`${this.emoji ? emoji : ''}[${time} ${type}] | ${line}`);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
stringc.split("\n").forEach((line) => {
|
||||||
|
console.log(`${this.emoji ? emojic : ''}[${timec} ${typec}] | ${line}`);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkTypes(types: string | string[]) {
|
||||||
|
if (!Array.isArray(types)) types = [types];
|
||||||
|
return types.some((type) => this.types.includes(type));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
debug(string: any, level: number, types?: string | string[]) {
|
||||||
|
if ((level || 0) <= this.debugLevel) {
|
||||||
|
if (types && !this.checkTypes(types)) return;
|
||||||
|
this.l(String(string), "DEBUG");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
};
|
log(string: any, types?: string | string[]) {
|
||||||
|
if (types && !this.checkTypes(types)) return;
|
||||||
|
this.l(String(string), "LOG");
|
||||||
|
}
|
||||||
|
|
||||||
|
info(string: any, types?: string | string[]) {
|
||||||
|
if (types && !this.checkTypes(types)) return;
|
||||||
|
this.l(String(string), "INFO");
|
||||||
|
}
|
||||||
|
|
||||||
|
warn(string: any, types?: string | string[]) {
|
||||||
|
if (types && !this.checkTypes(types)) return;
|
||||||
|
this.l(String(string), "WARN");
|
||||||
|
}
|
||||||
|
|
||||||
|
error(string: any, types?: string | string[]) {
|
||||||
|
if (types && !this.checkTypes(types)) return;
|
||||||
|
this.l(String(string), "ERROR");
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
"module": "CommonJS", /* Specify what module code is generated. */
|
"module": "ESNext", /* Specify what module code is generated. */
|
||||||
"rootDir": "./src/", /* Specify the root folder within your source files. */
|
"rootDir": "./src/", /* Specify the root folder within your source files. */
|
||||||
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||||
|
|
Loading…
Reference in a new issue