mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-24 09:45:35 +08:00
[Feature] 添加日志保留行数调节选项 (#217)
* feat: Add LogLevel option. * style: update debug log color. * fix: code lint, constant extract, i18 * chore: Add prettierignore * refactor: Remove LogType. * fix(type err.): type err * Update src/signals/request.ts Co-authored-by: kunish <17328586+kunish@users.noreply.github.com> Signed-off-by: sdttttt <Kaltsit@111.com> * refactor: var name change. * Update package.json Co-authored-by: kunish <17328586+kunish@users.noreply.github.com> Signed-off-by: sdttttt <Kaltsit@111.com> * feat: Add log max rows option. * style(format): format * fix: import err. * chore: reset. * Update package.json Co-authored-by: kunish <17328586+kunish@users.noreply.github.com> Signed-off-by: sdttttt <Kaltsit@111.com> * Update src/pages/Config.tsx Co-authored-by: kunish <17328586+kunish@users.noreply.github.com> Signed-off-by: sdttttt <Kaltsit@111.com> * Update src/pages/Config.tsx Co-authored-by: kunish <17328586+kunish@users.noreply.github.com> Signed-off-by: sdttttt <Kaltsit@111.com> --------- Signed-off-by: sdttttt <Kaltsit@111.com> Signed-off-by: sdttttt <sdttttt@163.com> Co-authored-by: kunish <17328586+kunish@users.noreply.github.com>
This commit is contained in:
parent
ef36decc3c
commit
b66dd8902d
@ -161,3 +161,5 @@ export enum LOG_LEVEL {
|
|||||||
Debug = 'debug',
|
Debug = 'debug',
|
||||||
Silent = 'silent',
|
Silent = 'silent',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const LOGS_TABLE_MAX_ROWS_LIST = [200, 300, 500, 800, 1000]
|
@ -67,6 +67,7 @@ export default {
|
|||||||
debug: 'debug',
|
debug: 'debug',
|
||||||
warning: 'warning',
|
warning: 'warning',
|
||||||
error: 'error',
|
error: 'error',
|
||||||
|
logMaxRows: 'Log Maxinum Reserved Rows',
|
||||||
xs: 'Extra small size',
|
xs: 'Extra small size',
|
||||||
sm: 'Small size',
|
sm: 'Small size',
|
||||||
md: 'Normal size',
|
md: 'Normal size',
|
||||||
|
@ -67,6 +67,7 @@ export default {
|
|||||||
debug: '调试',
|
debug: '调试',
|
||||||
warning: '警告',
|
warning: '警告',
|
||||||
error: '错误',
|
error: '错误',
|
||||||
|
logMaxRows: '日志最大保留行数',
|
||||||
xs: '超小尺寸',
|
xs: '超小尺寸',
|
||||||
sm: '小尺寸',
|
sm: '小尺寸',
|
||||||
md: '正常尺寸',
|
md: '正常尺寸',
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
import { Button } from '~/components'
|
import { Button } from '~/components'
|
||||||
import {
|
import {
|
||||||
LANG,
|
LANG,
|
||||||
|
LOGS_TABLE_MAX_ROWS_LIST,
|
||||||
LOG_LEVEL,
|
LOG_LEVEL,
|
||||||
MODE_OPTIONS,
|
MODE_OPTIONS,
|
||||||
PROXIES_ORDERING_TYPE,
|
PROXIES_ORDERING_TYPE,
|
||||||
@ -41,6 +42,7 @@ import {
|
|||||||
favNightTheme,
|
favNightTheme,
|
||||||
latencyTestTimeoutDuration,
|
latencyTestTimeoutDuration,
|
||||||
logLevel,
|
logLevel,
|
||||||
|
logMaxRows,
|
||||||
proxiesOrderingType,
|
proxiesOrderingType,
|
||||||
proxiesPreviewType,
|
proxiesPreviewType,
|
||||||
renderInTwoColumns,
|
renderInTwoColumns,
|
||||||
@ -51,6 +53,7 @@ import {
|
|||||||
setFavNightTheme,
|
setFavNightTheme,
|
||||||
setLatencyTestTimeoutDuration,
|
setLatencyTestTimeoutDuration,
|
||||||
setLogLevel,
|
setLogLevel,
|
||||||
|
setLogMaxRows,
|
||||||
setProxiesOrderingType,
|
setProxiesOrderingType,
|
||||||
setProxiesPreviewType,
|
setProxiesPreviewType,
|
||||||
setRenderInTwoColumns,
|
setRenderInTwoColumns,
|
||||||
@ -429,6 +432,26 @@ const ConfigForXd = () => {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<ConfigTitle>{t('logMaxRows')}</ConfigTitle>
|
||||||
|
|
||||||
|
<select
|
||||||
|
class="select select-bordered w-full max-w-xs"
|
||||||
|
value={rows}
|
||||||
|
onChange={(e) => {
|
||||||
|
setLogMaxRows(parseInt(e.target.value))
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<For each={LOGS_TABLE_MAX_ROWS_LIST}>
|
||||||
|
{(rows) => (
|
||||||
|
<option value={rows}>
|
||||||
|
{rows}
|
||||||
|
</option>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -7,9 +7,9 @@ import {
|
|||||||
} from '@tanstack/solid-table'
|
} from '@tanstack/solid-table'
|
||||||
import { For, Index, createEffect, createSignal } from 'solid-js'
|
import { For, Index, createEffect, createSignal } from 'solid-js'
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
import { LOGS_TABLE_MAX_ROWS, LOG_LEVEL } from '~/constants'
|
import { LOG_LEVEL } from '~/constants'
|
||||||
import { tableSize, tableSizeClassName, useWsRequest } from '~/signals'
|
import { tableSize, tableSizeClassName, useWsRequest } from '~/signals'
|
||||||
import { logLevel } from '~/signals/config'
|
import { logLevel, logMaxRows } from '~/signals/config'
|
||||||
import { Log } from '~/types'
|
import { Log } from '~/types'
|
||||||
|
|
||||||
type LogWithSeq = Log & { seq: number }
|
type LogWithSeq = Log & { seq: number }
|
||||||
@ -21,6 +21,7 @@ export default () => {
|
|||||||
const [logs, setLogs] = createSignal<LogWithSeq[]>([])
|
const [logs, setLogs] = createSignal<LogWithSeq[]>([])
|
||||||
|
|
||||||
const logsData = useWsRequest<Log>('logs', { level: logLevel() })
|
const logsData = useWsRequest<Log>('logs', { level: logLevel() })
|
||||||
|
const maxRows = logMaxRows()
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const data = logsData()
|
const data = logsData()
|
||||||
@ -29,7 +30,7 @@ export default () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setLogs((logs) => [{ ...data, seq }, ...logs].slice(0, LOGS_TABLE_MAX_ROWS))
|
setLogs((logs) => [{ ...data, seq }, ...logs].slice(0, maxRows))
|
||||||
|
|
||||||
seq++
|
seq++
|
||||||
})
|
})
|
||||||
|
@ -58,6 +58,11 @@ export const [logLevel, setLogLevel] = makePersisted(
|
|||||||
{ name: 'logLevel', storage: localStorage },
|
{ name: 'logLevel', storage: localStorage },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const [logMaxRows, setLogMaxRows] = makePersisted(createSignal(300), {
|
||||||
|
name: 'logMaxRows',
|
||||||
|
storage: localStorage,
|
||||||
|
})
|
||||||
|
|
||||||
export const tableSizeClassName = (size: TAILWINDCSS_SIZE) => {
|
export const tableSizeClassName = (size: TAILWINDCSS_SIZE) => {
|
||||||
let className = 'table-xs'
|
let className = 'table-xs'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user