mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
logger config depends on port and api config properties
This commit is contained in:
parent
d361def816
commit
64a0ac36ee
@ -4,7 +4,7 @@
|
|||||||
"access":
|
"access":
|
||||||
{
|
{
|
||||||
"type": "dateFile",
|
"type": "dateFile",
|
||||||
"filename": "../logs/backend/access.log",
|
"filename": "../logs/federation/access-%p.log",
|
||||||
"pattern": "yyyy-MM-dd",
|
"pattern": "yyyy-MM-dd",
|
||||||
"layout":
|
"layout":
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"apollo":
|
"apollo":
|
||||||
{
|
{
|
||||||
"type": "dateFile",
|
"type": "dateFile",
|
||||||
"filename": "../logs/backend/apollo.log",
|
"filename": "../logs/federation/apollo-%p.log",
|
||||||
"pattern": "yyyy-MM-dd",
|
"pattern": "yyyy-MM-dd",
|
||||||
"layout":
|
"layout":
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"backend":
|
"backend":
|
||||||
{
|
{
|
||||||
"type": "dateFile",
|
"type": "dateFile",
|
||||||
"filename": "../logs/backend/backend.log",
|
"filename": "../logs/federation/backend-%p.log",
|
||||||
"pattern": "yyyy-MM-dd",
|
"pattern": "yyyy-MM-dd",
|
||||||
"layout":
|
"layout":
|
||||||
{
|
{
|
||||||
@ -40,10 +40,10 @@
|
|||||||
"fileNameSep" : "_",
|
"fileNameSep" : "_",
|
||||||
"numBackups" : 30
|
"numBackups" : 30
|
||||||
},
|
},
|
||||||
"klicktipp":
|
"federation":
|
||||||
{
|
{
|
||||||
"type": "dateFile",
|
"type": "dateFile",
|
||||||
"filename": "../logs/backend/klicktipp.log",
|
"filename": "../logs/federation/apiversion-%v-%p.log",
|
||||||
"pattern": "yyyy-MM-dd",
|
"pattern": "yyyy-MM-dd",
|
||||||
"layout":
|
"layout":
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@
|
|||||||
"errorFile":
|
"errorFile":
|
||||||
{
|
{
|
||||||
"type": "dateFile",
|
"type": "dateFile",
|
||||||
"filename": "../logs/backend/errors.log",
|
"filename": "../logs/federation/errors-%p.log",
|
||||||
"pattern": "yyyy-MM-dd",
|
"pattern": "yyyy-MM-dd",
|
||||||
"layout":
|
"layout":
|
||||||
{
|
{
|
||||||
@ -123,11 +123,11 @@
|
|||||||
"level": "debug",
|
"level": "debug",
|
||||||
"enableCallStack": true
|
"enableCallStack": true
|
||||||
},
|
},
|
||||||
"klicktipp":
|
"federation":
|
||||||
{
|
{
|
||||||
"appenders":
|
"appenders":
|
||||||
[
|
[
|
||||||
"klicktipp",
|
"federation",
|
||||||
"out",
|
"out",
|
||||||
"errors"
|
"errors"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -75,7 +75,7 @@ if (
|
|||||||
const federation = {
|
const federation = {
|
||||||
FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null,
|
FEDERATION_DHT_TOPIC: process.env.FEDERATION_DHT_TOPIC || null,
|
||||||
FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null,
|
FEDERATION_DHT_SEED: process.env.FEDERATION_DHT_SEED || null,
|
||||||
FEDERATION_PORT: process.env.FEDERATION_PORT || 5001,
|
FEDERATION_PORT: process.env.FEDERATION_PORT || 5000,
|
||||||
FEDERATION_API: process.env.FEDERATION_API || '1_0',
|
FEDERATION_API: process.env.FEDERATION_API || '1_0',
|
||||||
FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null,
|
FEDERATION_COMMUNITY_URL: process.env.FEDERATION_COMMUNITY_URL || null,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
import DHT from '@hyperswarm/dht'
|
import DHT from '@hyperswarm/dht'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
import CONFIG from '@/config'
|
import CONFIG from '@/config'
|
||||||
import { Community as DbCommunity } from '@entity/Community'
|
import { Community as DbCommunity } from '@entity/Community'
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
class GetTestApiResult {
|
class GetTestApiResult {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
class GetTestApiResult {
|
class GetTestApiResult {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
class GetTestApiResult {
|
class GetTestApiResult {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
import { Field, ObjectType, Query, Resolver } from 'type-graphql'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
class GetTestApiResult {
|
class GetTestApiResult {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
// config
|
// config
|
||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { federationLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
export const getApiResolvers = () => {
|
export const getApiResolvers = () => {
|
||||||
logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`)
|
logger.info(`getApiResolvers...${CONFIG.FEDERATION_API}`)
|
||||||
|
|||||||
@ -7,21 +7,18 @@ import { startDHT } from '@/dht_node/index'
|
|||||||
import CONFIG from './config'
|
import CONFIG from './config'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// in case of active DHT running on port 5000 else running on (default=5001) CONFIG.FEDERATION_PORT
|
|
||||||
const port = CONFIG.FEDERATION_DHT_TOPIC ? 5000 : CONFIG.FEDERATION_PORT
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`FEDERATION_PORT=${CONFIG.FEDERATION_PORT}`)
|
console.log(`FEDERATION_PORT=${CONFIG.FEDERATION_PORT}`)
|
||||||
console.log(`FEDERATION_API=${CONFIG.FEDERATION_API}`)
|
console.log(`FEDERATION_API=${CONFIG.FEDERATION_API}`)
|
||||||
console.log(`configured: FEDERATION_DHT_TOPIC=${CONFIG.FEDERATION_DHT_TOPIC}`)
|
console.log(`configured: FEDERATION_DHT_TOPIC=${CONFIG.FEDERATION_DHT_TOPIC}`)
|
||||||
console.log(`depending on DHT_TOPIC using => port=${port}`)
|
|
||||||
const { app } = await createServer()
|
const { app } = await createServer()
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(CONFIG.FEDERATION_PORT, () => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Server is running at http://localhost:${port}`)
|
console.log(`Server is running at http://localhost:${CONFIG.FEDERATION_PORT}`)
|
||||||
if (CONFIG.GRAPHIQL) {
|
if (CONFIG.GRAPHIQL) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`GraphIQL available at http://localhost:${port}`)
|
console.log(`GraphIQL available at http://localhost:${CONFIG.FEDERATION_PORT}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { backendLogger } from './logger'
|
import { federationLogger as logger } from './logger'
|
||||||
import i18n from 'i18n'
|
import i18n from 'i18n'
|
||||||
|
|
||||||
i18n.configure({
|
i18n.configure({
|
||||||
@ -10,9 +10,9 @@ i18n.configure({
|
|||||||
// autoReload: true, // if this is activated the seeding hangs at the very end
|
// autoReload: true, // if this is activated the seeding hangs at the very end
|
||||||
updateFiles: false,
|
updateFiles: false,
|
||||||
objectNotation: true,
|
objectNotation: true,
|
||||||
logDebugFn: (msg) => backendLogger.debug(msg),
|
logDebugFn: (msg) => logger.debug(msg),
|
||||||
logWarnFn: (msg) => backendLogger.info(msg),
|
logWarnFn: (msg) => logger.info(msg),
|
||||||
logErrorFn: (msg) => backendLogger.error(msg),
|
logErrorFn: (msg) => logger.error(msg),
|
||||||
// this api is needed for email-template pug files
|
// this api is needed for email-template pug files
|
||||||
api: {
|
api: {
|
||||||
__: 't', // now req.__ becomes req.t
|
__: 't', // now req.__ becomes req.t
|
||||||
|
|||||||
@ -7,13 +7,27 @@ const options = JSON.parse(readFileSync(CONFIG.LOG4JS_CONFIG, 'utf-8'))
|
|||||||
|
|
||||||
options.categories.backend.level = CONFIG.LOG_LEVEL
|
options.categories.backend.level = CONFIG.LOG_LEVEL
|
||||||
options.categories.apollo.level = CONFIG.LOG_LEVEL
|
options.categories.apollo.level = CONFIG.LOG_LEVEL
|
||||||
|
let filename: string = options.appenders.federation.filename
|
||||||
|
if(CONFIG.FEDERATION_DHT_TOPIC) {
|
||||||
|
options.appenders.federation.filename = filename.replace('apiversion-%v', 'dht_'+CONFIG.FEDERATION_DHT_TOPIC).replace('%p', '5000')
|
||||||
|
} else {
|
||||||
|
options.appenders.federation.filename = filename.replace('%v', CONFIG.FEDERATION_API).replace('%p', CONFIG.FEDERATION_PORT.toString())
|
||||||
|
}
|
||||||
|
filename = options.appenders.access.filename
|
||||||
|
options.appenders.access.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
|
||||||
|
filename = options.appenders.apollo.filename
|
||||||
|
options.appenders.apollo.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
|
||||||
|
filename = options.appenders.backend.filename
|
||||||
|
options.appenders.backend.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
|
||||||
|
filename = options.appenders.errorFile.filename
|
||||||
|
options.appenders.errorFile.filename = filename.replace('%p', CONFIG.FEDERATION_PORT.toString())
|
||||||
|
|
||||||
log4js.configure(options)
|
log4js.configure(options)
|
||||||
|
|
||||||
const apolloLogger = log4js.getLogger('apollo')
|
const apolloLogger = log4js.getLogger('apollo')
|
||||||
const backendLogger = log4js.getLogger('backend')
|
const backendLogger = log4js.getLogger('backend')
|
||||||
const klickTippLogger = log4js.getLogger('klicktipp')
|
const federationLogger = log4js.getLogger('federation')
|
||||||
|
|
||||||
backendLogger.addContext('user', 'unknown')
|
backendLogger.addContext('user', 'unknown')
|
||||||
|
|
||||||
export { apolloLogger, backendLogger, klickTippLogger }
|
export { apolloLogger, backendLogger, federationLogger }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user