Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

debux

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debux - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

25

build/index.js

@@ -32,3 +32,3 @@ "use strict";

log(s, options) {
this.addCache(s ?? "null");
this.addCache(this.constructEntry(s, "log", options));
if (this.logLevel == level.all)

@@ -38,3 +38,3 @@ return Debux.consoleLog(this.constructMessage(s, "log", options));

error(s, options) {
this.addCache(s);
this.addCache(this.constructEntry(s, "error", options));
if (this.logLevel >= level.error)

@@ -44,3 +44,3 @@ return Debux.consoleLog(this.constructMessage(chalk_1.default.red(s), "error", options));

warn(s, options) {
this.addCache(s);
this.addCache(this.constructEntry(s, "warn", options));
if (this.logLevel >= level.warning)

@@ -50,3 +50,3 @@ return Debux.consoleLog(this.constructMessage(chalk_1.default.yellow(s), "warn", options));

info(s, options) {
this.addCache(s);
this.addCache(this.constructEntry(s, "info", options));
if (this.logLevel >= level.info)

@@ -76,2 +76,17 @@ return Debux.consoleLog(this.constructMessage(s, "info", options));

}
constructEntry(s, cmd, options) {
let msg = new Date().toUTCString() + seperator + cmd + seperator;
if (typeof options?.process == "string")
msg += options.process + seperator;
if (typeof options?.class == "string")
msg += options.class + seperator;
if (typeof options?.event == "string")
msg += options.event + seperator;
if (typeof options?.function == "string")
msg += options.function + seperator;
if (!s)
return msg.slice(0, msg.length - 3);
else
return msg + s;
}
getCMDString(cmd) {

@@ -90,3 +105,3 @@ switch (cmd) {

addCache(log) {
this.cache.push(new Date().toUTCString() + seperator + log);
this.cache.push(log);
if (this.cache.length > this.maxCacheSize)

@@ -93,0 +108,0 @@ this.cache.shift();

2

build/tests/test.js

@@ -8,3 +8,3 @@ "use strict";

const __1 = __importDefault(require(".."));
const debug = __1.default({ maxCacheSize: 10, logLevel: 3 });
const debug = __1.default({ maxCacheSize: 10, logLevel: 4 });
debug.log("this is a log", {

@@ -11,0 +11,0 @@ process: "process",

{
"name": "debux",
"version": "0.3.3",
"version": "0.4.0",
"description": "Easy-to-use library for debugging your code",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -7,2 +7,4 @@ # Debux

![image](https://user-images.githubusercontent.com/51192395/124608268-411fa700-de77-11eb-9b98-d27ef98dd953.png)
# Support

@@ -14,2 +16,4 @@

calling `debux()` will always return the same instance on debux that was initialized within the same process!
```js

@@ -23,5 +27,78 @@ const debux = require("debux");

Docs are still in a WIP state!
Different methods
```js
debug.log("this is a log", {
process: "process",
class: "className",
function: "function",
event: "event"
});
debug.error("this is an error", {
process: "process",
class: "className",
function: "function",
event: "event"
});
Copyright (c) 2020 MatteZ02
debug.warn("this is a warning", {
process: "process",
class: "className",
function: "function",
event: "event"
});
debug.info("this is info", {
process: "process",
class: "className",
function: "function",
event: "event"
});
debug.logs() // will log all logs in the cache
/*
[
'Tue, 06 Jul 2021 13:18:24 GMT | log | process | className | event | function | this is a log',
'Tue, 06 Jul 2021 13:18:24 GMT | error | process | className | event | function | this is an error',
'Tue, 06 Jul 2021 13:18:24 GMT | warn | process | className | event | function | this is a warning',
'Tue, 06 Jul 2021 13:18:24 GMT | info | process | className | event | function | this is info'
]
De
*/
```
## Options
### log
`debux.log(string | null, Options?)` logs a simple informative log
### error
`debux.error(string, Options?)` logs an error
### warn
`debux.warn(string, Options?)` logs a warning
### info
`debux.info(string, Options?)` logs information about code
```ts
interface Options {
process?: string;// the process this log was created on
class?: string;// the class this log was created in
function?: string;// the function this log came from
event?: string;// the event this log is apart of
}
interface constructOptions {
maxCacheSize?: number;// how many logs to cache at a time
logLevel?: level;// which logs should be logged into console directly
}
export enum level {
nothing = 0,// won't log anything to console
error = 1,// only logs errors
warning = 2,// logs warnings and errors
info = 3,// logs info, warnings and errors
all = 4// logs everything
}
```
Copyright (c) 2021 MatteZ02

@@ -92,3 +92,3 @@ import chalk from "chalk";

let msg: string =
new Date().toUTCString() + seperator + this.getCMDString(cmd);
new Date().toUTCString() + seperator + cmd + seperator;
if (typeof options?.process == "string") msg += options.process + seperator;

@@ -116,5 +116,5 @@ if (typeof options?.class == "string") msg += options.class + seperator;

private addCache(log: string): void {
this.cache.push(new Date().toUTCString() + seperator + log);
this.cache.push(log);
if (this.cache.length > this.maxCacheSize) this.cache.shift();
}
}
//@ts-ignore
import debux from "..";
const debug = debux({ maxCacheSize: 10, logLevel: 3 });
const debug = debux({ maxCacheSize: 10, logLevel: 4 });

@@ -6,0 +6,0 @@ debug.log("this is a log", {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc