-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* logger function created * logs folder added to store logs * utility function to show output * logProcessOutput function to show stdout and stderr * app.log added in .gitignore * app.log path corrected * file app.log deleted
- Loading branch information
Showing
4 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
*.env | ||
*.env | ||
/logs/app.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
const logFilePath = path.join(__dirname, '../../logs/'); | ||
const logFileName = 'app.log'; | ||
const logFileFullPath = path.join(logFilePath, logFileName); | ||
|
||
export const logger = { | ||
log: (message: string): void => { | ||
const timeStamp = new Date().toISOString(); | ||
const logMessage = `${timeStamp} - ${message}\n`; | ||
console.log(message); | ||
if (!fs.existsSync(logFileFullPath)) { | ||
fs.writeFileSync(logFileFullPath, '', { encoding: 'utf-8' }); | ||
} | ||
fs.appendFileSync(logFileFullPath, logMessage, { encoding: 'utf-8' }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters