Files
authentik/packages/logger-js/lib/node.js
dependabot[bot] 8262989de0 web: bump typescript from 5.9.3 to 6.0.2 in /web (#21107)
* Bump related TS packages.

* Fix type.

* Fix styles.

* web: bump typescript from 5.9.3 to 6.0.2 in /web

Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.9.3 to 6.0.2.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.9.3...v6.0.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Partial upgrade.

* Add dep.

* Re-add preinstall.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-26 01:35:40 +01:00

82 lines
1.7 KiB
JavaScript

/**
* Application logger.
*
* @import { LoggerOptions, Level } from "pino"
* @import { PrettyOptions } from "pino-pretty"
* @import { IConsoleLogger } from "./shared.js"
*/
/// <reference types="../types/node.js" />
import { fixture, prefix } from "./shared.js";
export * from "./shared.js";
let warnedAboutPino = false;
const { pino } = await import("pino").catch(() => {
if (!warnedAboutPino) {
console.warn(
`Pino is not available. Falling back to a lightweight console logger.
Please install Pino to get the full logging experience: npm install pino`,
);
warnedAboutPino = true;
}
return import("./shared.js").then((module) => ({ pino: module.pinoLight }));
});
//#region Constants
/**
* Default options for creating a Pino logger.
*
* @category Logger
* @satisfies {LoggerOptions<never, false>}
*/
export const DEFAULT_PINO_LOGGER_OPTIONS = {
enabled: true,
level: "info",
transport: {
target: "./transport.js",
options: /** @satisfies {PrettyOptions} */ ({
colorize: true,
}),
},
};
//#endregion
//#region Functions
/**
* Read the log level from the environment.
* @return {Level}
*/
export function readLogLevel() {
return process.env.AK_LOG_LEVEL || DEFAULT_PINO_LOGGER_OPTIONS.level;
}
/**
* A singleton logger instance for Node.js.
*
* ```js
* import { ConsoleLogger } from "#logger/node";
*
* ConsoleLogger.info("Hello, world!");
* ```
*
* @runtime node
* @type {IConsoleLogger}
*/
export const ConsoleLogger = Object.assign(
pino({
...DEFAULT_PINO_LOGGER_OPTIONS,
level: readLogLevel(),
}),
{
fixture,
prefix,
},
);