use log configuration section to build the archive content
closes #1006
Contributed-by: @nahueld
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
import { createWriteStream, readdirSync } from 'node:fs'
// Partial Copyright Jerome Benoit. 2021-2024. All Rights Reserved.
import { createWriteStream, readdirSync } from 'node:fs'
-import { dirname, join, resolve } from 'node:path'
+import { dirname, extname, join, resolve } from 'node:path'
import { URL, fileURLToPath } from 'node:url'
import type { ValidateFunction } from 'ajv'
import { URL, fileURLToPath } from 'node:url'
import type { ValidateFunction } from 'ajv'
import {
type ChangeConfigurationRequest,
type ChangeConfigurationResponse,
import {
type ChangeConfigurationRequest,
type ChangeConfigurationResponse,
ErrorType,
type GenericResponse,
GenericStatus,
ErrorType,
type GenericResponse,
GenericStatus,
type GetDiagnosticsResponse,
type IncomingRequestHandler,
type JsonType,
type GetDiagnosticsResponse,
type IncomingRequestHandler,
type JsonType,
OCPP16AuthorizationStatus,
OCPP16AvailabilityType,
type OCPP16BootNotificationRequest,
OCPP16AuthorizationStatus,
OCPP16AvailabilityType,
type OCPP16BootNotificationRequest,
type UnlockConnectorResponse
} from '../../../types/index.js'
import {
type UnlockConnectorResponse
} from '../../../types/index.js'
import {
Constants,
convertToDate,
convertToInt,
Constants,
convertToDate,
convertToInt,
if (uri.protocol.startsWith('ftp:')) {
let ftpClient: Client | undefined
try {
if (uri.protocol.startsWith('ftp:')) {
let ftpClient: Client | undefined
try {
+ const logConfiguration = Configuration.getConfigurationSection<LogConfiguration>(
+ ConfigurationSection.log
+ )
const logFiles = readdirSync(resolve(dirname(fileURLToPath(import.meta.url)), '../'))
const logFiles = readdirSync(resolve(dirname(fileURLToPath(import.meta.url)), '../'))
- .filter(file => file.endsWith('.log'))
- .map(file => join('./', file))
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ .filter(file => file.endsWith(extname(logConfiguration.file!)))
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ .map(file => join(dirname(logConfiguration.file!), file))
const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz`
create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive))
ftpClient = new Client()
const diagnosticsArchive = `${chargingStation.stationInfo?.chargingStationId}_logs.tar.gz`
create({ gzip: true }, logFiles).pipe(createWriteStream(diagnosticsArchive))
ftpClient = new Client()