mirror of
https://github.com/dzeiocom/libs.git
synced 2025-04-23 19:32:14 +00:00
Merge branch 'master' of github.com:dzeiocom/libs
This commit is contained in:
commit
daed0b82e6
21608
packages/logger/package-lock.json
generated
Normal file
21608
packages/logger/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/logger",
|
"name": "@dzeio/logger",
|
||||||
"version": "2.0.4",
|
"version": "2.1.0",
|
||||||
"description": "My Personnal Logger",
|
"description": "My Personnal Logger",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -18,11 +18,11 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^4.5.0",
|
"@typescript-eslint/eslint-plugin": "^4.5.0",
|
||||||
"@typescript-eslint/parser": "^4.5.0",
|
"@typescript-eslint/parser": "^4.5.0",
|
||||||
"eslint": "^7.4.0",
|
"eslint": "^7.4.0",
|
||||||
"parcel": "^1.12.4",
|
"parcel": "1.12.3",
|
||||||
"typescript": "^4.0.3"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "yarn build",
|
"prepublishOnly": "npm run build",
|
||||||
"build": "parcel build src/index.ts --out-file browser.js --experimental-scope-hoisting && tsc",
|
"build": "parcel build src/index.ts --out-file browser.js --experimental-scope-hoisting && tsc",
|
||||||
"test": "ts-node test"
|
"test": "ts-node test"
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,14 @@ export default class Logger implements Console {
|
|||||||
*/
|
*/
|
||||||
private static loggers: Array<Logger> = []
|
private static loggers: Array<Logger> = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Define if you want a timestamp with your logs
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberof Logger
|
||||||
|
*/
|
||||||
|
public static timestamp = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Console memory
|
* Console memory
|
||||||
* (IDK what it is)
|
* (IDK what it is)
|
||||||
@ -367,7 +375,16 @@ export default class Logger implements Console {
|
|||||||
}
|
}
|
||||||
const res: Array<any> = [
|
const res: Array<any> = [
|
||||||
`${this.blackOrWhite('[ ')}${spacers[0]}${blue(prefix)}${spacers[1]}${this.blackOrWhite(' ]')}:`
|
`${this.blackOrWhite('[ ')}${spacers[0]}${blue(prefix)}${spacers[1]}${this.blackOrWhite(' ]')}:`
|
||||||
].concat(
|
]
|
||||||
|
|
||||||
|
if (Logger.timestamp) {
|
||||||
|
const now = new Date()
|
||||||
|
const h = now.getHours() >= 10 ? now.getHours().toString() : `0${now.getHours()}`
|
||||||
|
const m = now.getMinutes() >= 10 ? now.getMinutes().toString() : `0${now.getMinutes()}`
|
||||||
|
const s = now.getSeconds() >= 10 ? now.getSeconds().toString() : `0${now.getSeconds()}`
|
||||||
|
res.unshift(`${this.blackOrWhite('<')}${yellow(h)}:${yellow(m)}:${yellow(s)}${this.blackOrWhite('>')}`)
|
||||||
|
}
|
||||||
|
return res.concat(
|
||||||
message.map((el) => {
|
message.map((el) => {
|
||||||
if (typeof el === 'object') {
|
if (typeof el === 'object') {
|
||||||
return el
|
return el
|
||||||
@ -381,7 +398,6 @@ export default class Logger implements Console {
|
|||||||
return typeof el !== 'string' ? yellow(el.toString()) : green(el)
|
return typeof el !== 'string' ? yellow(el.toString()) : green(el)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { logger as console } from '../src/Logger'
|
import Logger, { logger as console } from '../src/Logger'
|
||||||
|
|
||||||
|
Logger.timestamp = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test file is simple :D
|
* This test file is simple :D
|
||||||
|
Loading…
x
Reference in New Issue
Block a user