Logger Format Utility (src/format.ts)

nocobase · packages/core/logger/src/format.ts · typescript · Apache-2.0
dev-tools, infra, fw:node, tag:utility

Provides configurable formatting for application logs, supporting console, logfmt, and custom delimiters. Use this to standardize log output across the system.

// Source: https://github.com/nocobase/nocobase | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */

import chalk from 'chalk';
import winston from 'winston';
import { getLoggerFormat } from './config';
import { LoggerOptions } from './logger';
import { isEmpty } from 'lodash';

const DEFAULT_DELIMITER = '|';

const colorize = {};

/**
 * @internal
 */

export const getFormat = (format?: LoggerOptions['format']) => {
  const configFormat = format || getLoggerFormat();

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key