Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
autoreggol
Advanced tools
Changelog
0.4.0 (December 21, 2023)
enablePropertyLoging
to enablePropertyLogging
.Readme
A collection of handy decorators for auto logging class methods and properties based on es6 proxies and reflect-metadata.
Provide a LogFunction
for auto reggol to call.
const logger: LogFunction = (ctr, targetKey, targetValue, level) => {
console.log(`${level}: ${ctr.name}.${targetKey.toString()}`, targetValue);
};
Pass the logger function into the @AutoLog
decorator.
@AutoLog({ logger, level: "debug", enablePropertyLogging: true })
class Example {}
Full example
import { AutoLog } from "../src";
import { LogFunction } from "../src/base";
import { AutoLogLevel, AutoLogBypass } from "../src/method-decorators";
import {
AutoLogPropBypass,
AutoLogPropLevel,
} from "../src/property-decorators";
const logger: LogFunction = (ctr, targetKey, targetValue, level) => {
console.log(`${level}: ${ctr.name}.${targetKey.toString()}`, targetValue);
};
@AutoLog({ logger, level: "debug", enablePropertyLogging: true })
class Example {
private a = "foo";
private b = "bar";
@AutoLogPropLevel("warn")
private c = "baz";
private d = "qux";
private e = "quuz";
@AutoLogPropBypass
private f = "corge";
@AutoLogLevel("info")
private sanitize(str: string): string {
this.d;
this.e;
this.f;
return `A String ${str}`;
}
@AutoLogBypass
private doSomething(str: string): string {
this.d;
this.e;
this.f;
return `A String ${str}`;
}
run(args: { a: string; b: string }): string {
this.a;
this.b;
this.c;
this.doSomething("something");
return this.sanitize(args.a);
}
}
const example = new Example();
example.run({ a: "Hello", b: "World" });
class NonLoggedClass {
iDontLog() {
return "not me";
}
@AutoLogMe(logger)
iDoLog(argument: string) {
return `me please ${argument}`;
}
}
const nonLoggedClass = new NonLoggedClass();
nonLoggedClass.iDontLog();
nonLoggedClass.iDoLog("arg1");
Result
debug: Example.run [ { a: 'Hello', b: 'World' } ]
debug: Example.a foo
debug: Example.b bar
warn: Example.c baz
debug: Example.d qux
debug: Example.e quuz
info: Example.sanitize [ 'Hello' ]
debug: Example.d qux
debug: Example.e quuz
info: NonLoggedClass.iDoLog [ 'arg1' ]
FAQs
A collection of handy auto logging decorators.
The npm package autoreggol receives a total of 3,675 weekly downloads. As such, autoreggol popularity was classified as popular.
We found that autoreggol demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.