X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fcli.ts;h=58e2445ac47f0c40e9f1e4f2cafa1ff8c860ca26;hb=c3700e0ff9e174e7bad7e72d1d5a4e2e02627ef9;hp=67755022c182f4c7ae173cfe7e6106e0fd06d7e6;hpb=8d2be0ed7bb87283a1ec98609df6b82d83db706a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/cli.ts b/server/tools/cli.ts index 67755022c..58e2445ac 100644 --- a/server/tools/cli.ts +++ b/server/tools/cli.ts @@ -5,6 +5,7 @@ import { root } from '../../shared/extra-utils/miscs/miscs' import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels' import { Command } from 'commander' import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' +import { createLogger, format, transports } from 'winston' let configName = 'PeerTube/CLI' if (isTestInstance()) configName += `-${getAppNumber()}` @@ -119,9 +120,10 @@ function buildCommonVideoOptions (command: Command) { .option('-m, --comments-enabled', 'Enable comments') .option('-s, --support ', 'Video support text') .option('-w, --wait-transcoding', 'Wait transcoding before publishing the video') + .option('-v, --verbose ', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info') } -async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any) { +async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) { const defaultBooleanAttributes = { nsfw: false, commentsEnabled: true, @@ -147,7 +149,9 @@ async function buildVideoAttributesFromCommander (url: string, command: Command, licence: command[ 'licence' ] || defaultAttributes.licence || undefined, language: command[ 'language' ] || defaultAttributes.language || undefined, privacy: command[ 'privacy' ] || defaultAttributes.privacy || VideoPrivacy.PUBLIC, - support: command[ 'support' ] || defaultAttributes.support || undefined + support: command[ 'support' ] || defaultAttributes.support || undefined, + description: command[ 'videoDescription' ] || defaultAttributes.description || undefined, + tags: command[ 'tags' ] || defaultAttributes.tags || undefined } Object.assign(videoAttributes, booleanAttributes) @@ -173,11 +177,42 @@ function getServerCredentials (program: any) { }) } +function getLogger (logLevel = 'info') { + const logLevels = { + 0: 0, + error: 0, + 1: 1, + warn: 1, + 2: 2, + info: 2, + 3: 3, + verbose: 3, + 4: 4, + debug: 4 + } + + const logger = createLogger({ + levels: logLevels, + format: format.combine( + format.splat(), + format.simple() + ), + transports: [ + new (transports.Console)({ + level: logLevel + }) + ] + }) + + return logger +} + // --------------------------------------------------------------------------- export { version, config, + getLogger, getSettings, getNetrc, getRemoteObjectOrDie,