
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@amplication/logging-utils
Advanced tools
This library was generated with Nx.
Run nx build util-logging
to build the library.
Run nx test util-logging
to execute the unit tests via Jest.
Libraries should always log without relying on a logger framework. In order to do so, libraries should rely on the ILogger interface and any service/application will pass the proper logger class.
// library.class.ts
import { ILogger } from "@amplication/util/logging";
export class CakeFactory {
constructor(private readonly logger: ILogger){}
printInLog(message: string){
this.logger.info(message)
this.logger.error(message, new Error())
}
}
In your microservices, import the logger module and consume it in your root module.
// module.ts
import { Logger } from '@amplication/util/logging';
const logger = new Logger ({
isProduction: true,
component: "component-name",
logLevel: LogLevel.Warn
})
const logMe = () => {
logger.info("An info log message", { other: { value: 1 }})
// ....
}
The minimum log level can be configured also with the LOG_LEVEL
environment variable, instead of the logLevel: LogLevel.Warn
, to one of the following values:
debug
info
warn
error
A mocked provider can be used in unit tests. The following example explain how to use it
/// myservice.spec.ts
import { MockedLogger } from "@amplication/util/logging/test-utils";
//...
it('', () => {
const target = new Service(MockedLogger);
})
//...
FAQs
This library supplies a logger for Amplication Services
The npm package @amplication/logging-utils receives a total of 0 weekly downloads. As such, @amplication/logging-utils popularity was classified as not popular.
We found that @amplication/logging-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.