Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jun 20, 2024
1 parent ff072d7 commit a4e9d5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CLASS_PREFIX } from './const';
import { IRowConfigOptions, RowConfigMap, RowConfigMapRegExp, RowConfigMapRegExpCached } from './row-config';
import { syntaxHighlighter } from './highlighter';
import { IRecordInfo } from '@bluelovers/auto1111-pnginfo';
import { logger } from './logger';

export function _addRowCoreOptions(key: string, value: any, infoData: ILayoutInfoData)
{
Expand Down Expand Up @@ -34,7 +35,14 @@ export async function _addRowCore(key: string, value: any, infoData: ILayoutInfo
{
if (opts.decode === true)
{
value = JSON.parse(value)
try
{
value = JSON.parse(value)
}
catch (e)
{
logger.error(e)
}
}
else
{
Expand Down
13 changes: 11 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ import { EXTENSION_NAME } from './const';

function initLogger()
{
return (Object.keys(console) as (keyof typeof console)[])
const list = [
'log',
'error',
'debug',
'info',
'warn',
// @ts-ignore
] as const satisfies Extract<keyof typeof console, string>;

return (Object.keys(console) as Extract<keyof typeof console, string>[])
.reduce((log, method) => {

let fn = console[method];
if (typeof fn === 'function')
if (typeof fn === 'function' && list.includes(method as any))
{
// @ts-ignore
log[method] = fn.bind(console, EXTENSION_NAME)
Expand Down

0 comments on commit a4e9d5c

Please sign in to comment.