-
Notifications
You must be signed in to change notification settings - Fork 0
add logging and exception handling (Task 2) #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlanProphettSoftwire
wants to merge
12
commits into
main
Choose a base branch
from
task-2-logging-and-exception-handling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bd822da
add dodgy transaction data and set up logger
AlanProphettSoftwire bf00b5c
separate data parsing logic from csv parser
AlanProphettSoftwire 4b5dcbe
change module type to commonjs to support log4js
AlanProphettSoftwire 6901595
add .log files to .gitignore
AlanProphettSoftwire 7cca4fd
add import data checks and warning logs
AlanProphettSoftwire 035b148
fix formatting of files
AlanProphettSoftwire 380325e
fix package.json and exit after warning logic
AlanProphettSoftwire 5e41579
replace getTransactionData with csvService and improve logger impleme…
AlanProphettSoftwire 7bf11ed
improve import of date-fns
AlanProphettSoftwire d714405
remove remaining snake case variables
AlanProphettSoftwire 6996350
rename Record to record
AlanProphettSoftwire c8a45aa
add amount format check on parse
AlanProphettSoftwire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 +1,3 @@ | ||
| /node_modules | ||
| /dist | ||
| /dist | ||
| *.log |
This file contains hidden or 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,52 @@ | ||
| Date,From,To,Narrative,Amount | ||
| 01/01/2015,Laura B,Sarah T,Misc Morale,10.54 | ||
| 04/01/2015,Stephen S,Gergana I,Lunch,3.22 | ||
| 07/01/2015,Ben B,Jon A,Fantasy Football,9.93 | ||
| 11/01/2015,Ben B,Todd,Lunch,7.33 | ||
| 12/01/2015,Laura B,Ben B,Beers,8.94 | ||
| 15/01/2015,Todd,Rob S,Beers,10.19 | ||
| 16/01/2015,Laura B,Jon A,Lego Assistance,0.69 | ||
| 18/01/2015,Jon A,Sarah T,Coffee,10.73 | ||
| 22/01/2015,Gergana I,Todd,Coffee,0.8 | ||
| 24/01/2015,Gergana I,Chris W,Coffee,8.49 | ||
| 27/01/2015,Laura B,Tim L,Jenkins Fees,0.52 | ||
| 29/01/2015,Sam N,Chris W,Lunch,9.01 | ||
| 01/02/2015,Stephen S,Laura B,Coffee,7.53 | ||
| 02/02/2015,Stephen S,Rob S,Fantasy Football,7.43 | ||
| 04/02/2015,Rob S,Stephen S,Fantasy Football,5.78 | ||
| 06/02/2015,Dan W,Gergana I,Automated Testing Services,10.29 | ||
| 07/02/2015,Jon A,Chris W,Rails Consultancy,7.37 | ||
| 10/02/2015,Sam N,Gergana I,Sandbox Help,9.84 | ||
| 11/02/2015,Chris W,Stephen S,Misc Morale,0.68 | ||
| 13/02/2015,Laura B,Gergana I,Beers,6.56 | ||
| 16/02/2015,Chris W,Dan W,Jenkins Fees,1.28 | ||
| 17/02/2015,Sarah T,Dan W,Sandbox Help,11.48 | ||
| 18/02/2015,Stephen S,Rob S,Lego Assistance,4.83 | ||
| 21/02/2015,Dan W,Ben B,Pokemon Training,0.5 | ||
| 24/02/2015,Todd,Gergana I,Coffee,9.08 | ||
| 26/02/2015,Stephen S,Jon A,Pokemon Training,4.23 | ||
| 01/03/2015,Ben B,Sam N,Lunch,One Cheeseburger | ||
| 02/03/2015,Todd,Chris W,Sandbox Help,1.92 | ||
| 04/03/2015,Laura B,Jon A,Sandcastle Help,9.09 | ||
| 06/03/2015,Stephen S,Gergana I,Lego Assistance,9.4 | ||
| 08/03/2015,Ben B,Sam N,Pokemon Training,11.32 | ||
| 11/03/2015,Stephen S,Jon A,Sandcastle Help,11.57 | ||
| 15/03/2015,Todd,Sam N,Pokemon Training,2.29 | ||
| 19/03/2015,Laura B,Chris W,Coffee,9.96 | ||
| 21/03/2015,Jon A,Gergana I,Beers,7.54 | ||
| 25/03/2015,Gergana I,Ben B,Automated Testing Services,2.39 | ||
| 28/03/2015,Stephen S,Tim L,Lunch,5.83 | ||
| 29/03/2015,Gergana I,Ben B,Audit and Other Financial Services,10.85 | ||
| 30/03/2015,Tim L,Todd,Pokemon Training,8.6 | ||
| 02/04/2015,Stephen S,Chris W,Pokemon Training,1.11 | ||
| 05/04/2015,Chris W,Ben B,Lunch,0.96 | ||
| 09/04/2015,Chris W,Rob S,Audit and Other Financial Services,11.79 | ||
| 12/04/2015,Gergana I,Laura B,Stationary Items,8.37 | ||
| 13/04/2015,Laura B,Tim L,Services Rendered,1.27 | ||
| 15/04/2015,Ben B,Sam N,Lego Assistance,8.5 | ||
| 19/04/2015,Stephen S,Chris W,White Water Rafting,8.91 | ||
| 23/04/2015,Tim L,Todd,Misc Morale,8.1 | ||
| 24/04/2015,Tim L,Sarah T,Arcade Social,6.38 | ||
| 26/04/2015,Jon A,Todd,Stationary Items,8.44 | ||
| 27/04/2015,Ben B,Jon A,Pokemon Training,10.91 | ||
| Last Thursday,Sarah T,Dan W,Beers,5.42 |
This file contains hidden or 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,22 @@ | ||
| import { readFileSync } from "fs"; | ||
| import { parse } from "csv-parse/sync"; | ||
| import type { TransactionRecord } from "../types/transactionRecord"; | ||
| import type { FileDataRecord } from "../types/fileDataRecord"; | ||
| import { getParsedObjectsToTransactionRecords } from "../utils/parseObjectToTransactionRecord"; | ||
|
|
||
| const HEADERS = ["Date", "From", "To", "Narrative", "Amount"]; | ||
|
|
||
| export const csvService = (filePath: string): TransactionRecord[] => { | ||
| const fileContent = readFileSync(filePath, { encoding: "utf-8" }); | ||
|
|
||
| const records = parse(fileContent, { | ||
| delimiter: ",", | ||
| columns: HEADERS, | ||
| from_line: 2, | ||
| }); | ||
|
|
||
| let transactionRecords: TransactionRecord[] = | ||
| getParsedObjectsToTransactionRecords(records as FileDataRecord[]); | ||
|
|
||
| return transactionRecords; | ||
| }; |
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,7 @@ | ||
| export interface FileDataRecord { | ||
| Date: string; | ||
| From: string; | ||
| To: string; | ||
| Narrative: string; | ||
| Amount: string; | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 { configure } from "log4js"; | ||
|
|
||
| var loggerConfiguration = configure({ | ||
| appenders: { | ||
| file: { type: "file", filename: "logs.log" }, | ||
| out: { type: "stdout" }, | ||
| }, | ||
| categories: { | ||
| default: { appenders: ["file", "out"], level: "error" }, | ||
| }, | ||
| }) | ||
|
|
||
| export function getLogger(filename: string): ReturnType<typeof loggerConfiguration.getLogger> | ||
| { | ||
| const logger = loggerConfiguration.getLogger(filename); | ||
| logger.level = "debug"; | ||
| return logger; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting - how come you've made this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log4jshad a couple of dependencies which requiredcommonjsto compile. It might be worth finding another library which is supported without changing tocommonjs- this was just a quick solution.