-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61b6d74
commit 7962528
Showing
2 changed files
with
7 additions
and
4 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,14 +1,16 @@ | ||
import { format } from 'winston'; | ||
|
||
export default function CSVFormatter(fields, options={}){ | ||
export default function CSVFormatter(fields, options = {}) { | ||
const delim = options.delimiter || ';'; | ||
|
||
|
||
return format.printf(logObject => { | ||
const data = fields.map(key => { | ||
const value = logObject[key]; | ||
|
||
return value === undefined ? '' : value; | ||
}); | ||
|
||
return data.join(delim); | ||
}); | ||
} | ||
} |
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,2 +1,3 @@ | ||
import CSVFormatter from './Format'; | ||
|
||
export default CSVFormatter; |