diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/models/server/client-log-create.model.ts | 11 | ||||
-rw-r--r-- | shared/models/server/client-log-level.type.ts | 1 | ||||
-rw-r--r-- | shared/models/server/index.ts | 4 | ||||
-rw-r--r-- | shared/models/server/log-level.type.ts | 1 | ||||
-rw-r--r-- | shared/models/server/server-log-level.type.ts | 1 | ||||
-rw-r--r-- | shared/server-commands/logs/logs-command.ts | 17 |
6 files changed, 31 insertions, 4 deletions
diff --git a/shared/models/server/client-log-create.model.ts b/shared/models/server/client-log-create.model.ts new file mode 100644 index 000000000..c9dc65568 --- /dev/null +++ b/shared/models/server/client-log-create.model.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { ClientLogLevel } from './client-log-level.type' | ||
2 | |||
3 | export interface ClientLogCreate { | ||
4 | message: string | ||
5 | url: string | ||
6 | level: ClientLogLevel | ||
7 | |||
8 | stackTrace?: string | ||
9 | userAgent?: string | ||
10 | meta?: string | ||
11 | } | ||
diff --git a/shared/models/server/client-log-level.type.ts b/shared/models/server/client-log-level.type.ts new file mode 100644 index 000000000..18dea2751 --- /dev/null +++ b/shared/models/server/client-log-level.type.ts | |||
@@ -0,0 +1 @@ | |||
export type ClientLogLevel = 'warn' | 'error' | |||
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts index 0f7646c7a..a9136f3d4 100644 --- a/shared/models/server/index.ts +++ b/shared/models/server/index.ts | |||
@@ -1,14 +1,16 @@ | |||
1 | export * from './about.model' | 1 | export * from './about.model' |
2 | export * from './broadcast-message-level.type' | 2 | export * from './broadcast-message-level.type' |
3 | export * from './client-log-create.model' | ||
4 | export * from './client-log-level.type' | ||
3 | export * from './contact-form.model' | 5 | export * from './contact-form.model' |
4 | export * from './custom-config.model' | 6 | export * from './custom-config.model' |
5 | export * from './debug.model' | 7 | export * from './debug.model' |
6 | export * from './emailer.model' | 8 | export * from './emailer.model' |
7 | export * from './job.model' | 9 | export * from './job.model' |
8 | export * from './log-level.type' | ||
9 | export * from './peertube-problem-document.model' | 10 | export * from './peertube-problem-document.model' |
10 | export * from './server-config.model' | 11 | export * from './server-config.model' |
11 | export * from './server-debug.model' | 12 | export * from './server-debug.model' |
12 | export * from './server-error-code.enum' | 13 | export * from './server-error-code.enum' |
13 | export * from './server-follow-create.model' | 14 | export * from './server-follow-create.model' |
15 | export * from './server-log-level.type' | ||
14 | export * from './server-stats.model' | 16 | export * from './server-stats.model' |
diff --git a/shared/models/server/log-level.type.ts b/shared/models/server/log-level.type.ts deleted file mode 100644 index 4afb92d11..000000000 --- a/shared/models/server/log-level.type.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'audit' | ||
diff --git a/shared/models/server/server-log-level.type.ts b/shared/models/server/server-log-level.type.ts new file mode 100644 index 000000000..f0f31a4ae --- /dev/null +++ b/shared/models/server/server-log-level.type.ts | |||
@@ -0,0 +1 @@ | |||
export type ServerLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'audit' | |||
diff --git a/shared/server-commands/logs/logs-command.ts b/shared/server-commands/logs/logs-command.ts index 8f63383ea..1c5de7f59 100644 --- a/shared/server-commands/logs/logs-command.ts +++ b/shared/server-commands/logs/logs-command.ts | |||
@@ -1,12 +1,25 @@ | |||
1 | import { HttpStatusCode, LogLevel } from '@shared/models' | 1 | import { ClientLogCreate, HttpStatusCode, ServerLogLevel } from '@shared/models' |
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
3 | 3 | ||
4 | export class LogsCommand extends AbstractCommand { | 4 | export class LogsCommand extends AbstractCommand { |
5 | 5 | ||
6 | createLogClient (options: OverrideCommandOptions & { payload: ClientLogCreate }) { | ||
7 | const path = '/api/v1/server/logs/client' | ||
8 | |||
9 | return this.postBodyRequest({ | ||
10 | ...options, | ||
11 | |||
12 | path, | ||
13 | fields: options.payload, | ||
14 | implicitToken: true, | ||
15 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
16 | }) | ||
17 | } | ||
18 | |||
6 | getLogs (options: OverrideCommandOptions & { | 19 | getLogs (options: OverrideCommandOptions & { |
7 | startDate: Date | 20 | startDate: Date |
8 | endDate?: Date | 21 | endDate?: Date |
9 | level?: LogLevel | 22 | level?: ServerLogLevel |
10 | tagsOneOf?: string[] | 23 | tagsOneOf?: string[] |
11 | }) { | 24 | }) { |
12 | const { startDate, endDate, tagsOneOf, level } = options | 25 | const { startDate, endDate, tagsOneOf, level } = options |