Skip to content

Commit

Permalink
fix(logs): logs location is configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
saadjutt01 committed Jul 16, 2022
1 parent 92fda18 commit e024a92
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ HELMET_CSP_CONFIG_PATH=./csp.config.json
# Docs: https://www.npmjs.com/package/morgan#predefined-formats
LOG_FORMAT_MORGAN=
# This location is for server logs with classical UNIX logrotate behavior
LOG_LOCATION=./sasjs_root/logs
# A comma separated string that defines the available runTimes.
# Priority is given to the runtime that comes first in the string.
# Possible options at the moment are sas and js
Expand Down
3 changes: 2 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node

SASJS_ROOT=./sasjs_root

LOG_FORMAT_MORGAN=common
LOG_FORMAT_MORGAN=common
LOG_LOCATION=./sasjs_root/logs
1 change: 1 addition & 0 deletions api/src/types/system/process.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ declare namespace NodeJS {
sasLoc?: string
nodeLoc?: string
driveLoc: string
logsLoc: string
sasSessionController?: import('../../controllers/internal').SASSessionController
jsSessionController?: import('../../controllers/internal').JSSessionController
appStreamConfig: import('../').AppStreamConfig
Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const getDesktopUserAutoExecPath = () =>

export const getSasjsRootFolder = () => process.driveLoc

export const getLogFolder = () => process.logsLoc

export const getAppStreamConfigPath = () =>
path.join(getSasjsRootFolder(), 'appStreamConfig.json')

Expand All @@ -32,8 +34,6 @@ export const getUploadsFolder = () => path.join(getSasjsRootFolder(), 'uploads')

export const getFilesFolder = () => path.join(getSasjsRootFolder(), 'files')

export const getLogFolder = () => path.join(getSasjsRootFolder(), 'logs')

export const getWeboutFolder = () => path.join(getSasjsRootFolder(), 'webouts')

export const getSessionsFolder = () =>
Expand Down
9 changes: 9 additions & 0 deletions api/src/utils/setProcessVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ export const setProcessVariables = async () => {
await createFolder(absPath)
process.driveLoc = getRealPath(absPath)

const { LOG_LOCATION } = process.env
const absLogsPath = getAbsolutePath(
LOG_LOCATION ?? `sasjs_root${path.sep}logs`,
process.cwd()
)
await createFolder(absLogsPath)
process.logsLoc = getRealPath(absLogsPath)

console.log('sasLoc: ', process.sasLoc)
console.log('sasDrive: ', process.driveLoc)
console.log('sasLogs: ', process.logsLoc)
console.log('runTimes: ', process.runTimes)
}

0 comments on commit e024a92

Please sign in to comment.