admin/config: better name for "error log"
Massimo Melina committed
May 6, 2022 at 19:57 UTC
7185ec68491cfe7b3c32c723e8be873eb0546f19
2 files changed
+10
-9
admin/src/ConfigPage.ts
+3
-2
@@ -21,7 +21,7 @@ subscribeKey(state, 'config', recalculateChanges)
21
22
export const logLabels = {
23
log: "Access log file",
24
- error_log: "Error log file"
24
+ error_log: "Access error log file"
25
}
26
27
export default function ConfigPage() {
@@ -90,7 +90,8 @@ export default function ConfigPage() {
90
validate: x => x || !admins || admins.length>0 || "First create at least one admin account",
91
helperText: "To access Admin without entering credentials"
92
},
93
- ...Object.entries(logLabels).map(a => ({ k: a[0], label: a[1], lg: 3 })),
93
+ { k: 'log', label: logLabels.log, lg: 3, helperText: "Requests are logged here" },
94
+ { k: 'error_log', label: logLabels.error_log, lg: 3, placeholder: "errors go to main log", helperText: "If you want errors in a different log" },
95
{ k: 'log_rotation', comp: SelectField, options: [{ value:'', label:"disabled" }, 'daily', 'weekly', 'monthly' ],
96
helperText: "To avoid an endlessly-growing single log file, you can opt for rotation"
97
},
server/src/log.ts
+7
-7
@@ -39,18 +39,18 @@ class Logger {
39
40
// we'll have names same as config keys. These are used also by the get_log api.
41
const accessLogger = new Logger('log')
42
-const errorLogger = new Logger('error_log')
43
-export const loggers = [accessLogger, errorLogger]
42
+const accessErrorLog = new Logger('error_log')
43
+export const loggers = [accessLogger, accessErrorLog]
44
45
defineConfig('log', 'access.log').sub(path => {
46
- console.debug('log file: ' + (path || 'disabled'))
46
+ console.debug('access log file: ' + (path || 'disabled'))
47
accessLogger.setPath(path)
48
})
49
50
-const errorLogFile = defineConfig('error_log', 'error.log')
50
+const errorLogFile = defineConfig(accessErrorLog.name, 'access-error.log')
51
errorLogFile.sub(path => {
52
- console.debug('error log: ' + (path || 'disabled'))
53
- errorLogger.setPath(path)
52
+ console.debug('access error log: ' + (path || 'disabled'))
53
+ accessErrorLog.setPath(path)
54
})
55
56
const logRotation = defineConfig('log_rotation', 'weekly')
@@ -59,7 +59,7 @@ export function log(): Koa.Middleware {
59
return async (ctx, next) => { // wrapping in a function will make it use current 'mw' value
60
await next()
61
const isError = ctx.status >= 400
62
- const logger = isError && errorLogger || accessLogger
62
+ const logger = isError && accessErrorLog || accessLogger
63
const rotate = logRotation.get()?.[0]
64
let { stream, last, path } = logger
65
if (!stream) return