mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
remove relative import from ditto/utils in DittoConf
This commit is contained in:
parent
e2ce3f32c3
commit
319620a414
2 changed files with 2 additions and 8 deletions
|
|
@ -11,8 +11,6 @@ import { getEcdsaPublicKey } from './utils/crypto.ts';
|
||||||
import { optionalBooleanSchema, optionalNumberSchema } from './utils/schema.ts';
|
import { optionalBooleanSchema, optionalNumberSchema } from './utils/schema.ts';
|
||||||
import { mergeURLPath } from './utils/url.ts';
|
import { mergeURLPath } from './utils/url.ts';
|
||||||
|
|
||||||
import { VALID_LOG_TYPES } from '../ditto/utils/logi.ts';
|
|
||||||
|
|
||||||
/** Ditto application-wide configuration. */
|
/** Ditto application-wide configuration. */
|
||||||
export class DittoConf {
|
export class DittoConf {
|
||||||
constructor(private env: { get(key: string): string | undefined }) {
|
constructor(private env: { get(key: string): string | undefined }) {
|
||||||
|
|
@ -257,12 +255,10 @@ export class DittoConf {
|
||||||
level ||= 'debug';
|
level ||= 'debug';
|
||||||
scopes ||= '';
|
scopes ||= '';
|
||||||
|
|
||||||
if (fmt && !VALID_LOG_TYPES.includes(fmt)) {
|
if (fmt !== 'jsonl' && fmt !== 'pretty') fmt = 'jsonl';
|
||||||
throw new Error(`Invalid log type supplied: Valid types are [${VALID_LOG_TYPES.join('|')}].`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fmt: (fmt ?? 'jsonl') as 'jsonl' | 'pretty',
|
fmt: fmt as 'jsonl' | 'pretty',
|
||||||
level,
|
level,
|
||||||
scopes: scopes.split(',').filter(Boolean),
|
scopes: scopes.split(',').filter(Boolean),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,6 @@ const pair = (key: string, value: LogiValue | undefined) => {
|
||||||
return `${key}: ${prettyPrint(value || '')}`;
|
return `${key}: ${prettyPrint(value || '')}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const VALID_LOG_TYPES = ['jsonl', 'pretty'];
|
|
||||||
|
|
||||||
export const createLogiHandler = (conf: DittoConf, defaultHandler: LogiHandler) => (log: LogiLog) => {
|
export const createLogiHandler = (conf: DittoConf, defaultHandler: LogiHandler) => (log: LogiLog) => {
|
||||||
const { fmt, level, scopes } = conf.logConfig;
|
const { fmt, level, scopes } = conf.logConfig;
|
||||||
if (fmt === 'jsonl') return defaultHandler(log);
|
if (fmt === 'jsonl') return defaultHandler(log);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue