1
1
mirror of https://github.com/leon-ai/leon.git synced 2025-01-03 22:28:10 +03:00

refactor(server): make use of consts for logger matters

This commit is contained in:
louistiti 2022-09-04 14:18:53 +08:00
parent 819e57a2c2
commit 58dc881a83
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6
4 changed files with 8 additions and 4 deletions

View File

@ -28,3 +28,5 @@ export const TTS_PROVIDER = process.env['LEON_TTS_PROVIDER']
export const HAS_OVER_HTTP = process.env['LEON_OVER_HTTP'] === 'true'
export const HTTP_API_KEY = process.env['LEON_HTTP_API_KEY']
export const HTTP_API_LANG = process.env['LEON_HTTP_API_LANG']
export const HAS_LOGGER = process.env['LEON_LOGGER'] === 'true'

View File

@ -1,6 +1,7 @@
import { version } from '@@/package.json'
import {
HAS_AFTER_SPEECH,
HAS_LOGGER,
HAS_STT,
HAS_TTS,
STT_PROVIDER,
@ -22,7 +23,7 @@ const getInfo = async (fastify, options) => {
code: 'info_pulled',
message,
after_speech: HAS_AFTER_SPEECH,
logger: process.env.LEON_LOGGER === 'true',
logger: HAS_LOGGER,
stt: {
enabled: HAS_STT,
provider: STT_PROVIDER

View File

@ -6,6 +6,7 @@ import { join } from 'path'
import { version } from '@@/package.json'
import { endpoints } from '@@/core/skills-endpoints.json'
import {
HAS_LOGGER,
HAS_OVER_HTTP,
HAS_STT,
HAS_TTS,
@ -379,7 +380,7 @@ server.init = async () => {
log.success(`The current time zone is ${date.timeZone()}`)
const sLogger = process.env.LEON_LOGGER !== 'true' ? 'disabled' : 'enabled'
const sLogger = !HAS_LOGGER ? 'disabled' : 'enabled'
log.success(`Collaborative logger ${sLogger}`)
await addProvider('1')

View File

@ -10,7 +10,7 @@ import kill from 'tree-kill'
import { langs } from '@@/core/langs.json'
import { version } from '@@/package.json'
import { IS_TESTING_ENV } from '@/constants'
import { HAS_LOGGER, IS_TESTING_ENV } from '@/constants'
import Ner from '@/core/ner'
import log from '@/helpers/log'
import string from '@/helpers/string'
@ -243,7 +243,7 @@ class Nlu {
*/
sendLog(utterance) {
/* istanbul ignore next */
if (process.env.LEON_LOGGER === 'true' && !IS_TESTING_ENV) {
if (HAS_LOGGER && !IS_TESTING_ENV) {
this.request
.post('https://logger.getleon.ai/v1/expressions')
.set('X-Origin', 'leon-core')