-
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.
* Renamed health check end point from /ping.xml to /pingdom/ping.xml. (#499) Also call the updated end point on the Data Hub API. Test to be written as part of TET-664 * Use ASIM formatted logger (#518) * Use ASIM formatted logger on production environments. * add initial build configuration * Fix linting errors * Update healthcheck in test * Skip pingdom test --------- Co-authored-by: Marijn Kampf <marijn.kampf@digital.trade.gov.uk> Co-authored-by: Lawrence Goldstien <lawrence.goldstein@digital.trade.gov.uk>
- Loading branch information
1 parent
8872e9b
commit e0f60a9
Showing
11 changed files
with
361 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
repository: omis | ||
builder: | ||
name: paketobuildpacks/builder-jammy-full | ||
version: 0.3.339 |
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,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit early if something goes wrong | ||
set -e | ||
|
||
# Add commands below to run as part of the pre_build phase | ||
|
||
# The build system requires a Procfile be present | ||
echo "web: npm start" > Procfile |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,10 +1,79 @@ | ||
const winston = require('winston') | ||
|
||
const { createLogger, transports, format } = winston | ||
|
||
const config = require('../../../config') | ||
|
||
const logger = new winston.createLogger({ | ||
const eventTypes = { | ||
expressStartup: 'express.startup', | ||
expressRequest: 'express.request', | ||
} | ||
|
||
const asimFormat = format.printf( | ||
({ level, message, timestamp, eventType = eventTypes.expressRequest }) => { | ||
return JSON.stringify({ | ||
EventMessage: message, | ||
EventCount: 1, | ||
EventStartTime: timestamp, | ||
EventEndTime: timestamp, | ||
EventType: eventType, | ||
EventResult: 'NA', | ||
EventSeverity: getEventSeverity(level), | ||
EventOriginalSeverity: level, | ||
EventSchema: 'ProcessEvent', | ||
EventSchemaVersion: '0.1.4', | ||
ActingAppType: 'Express', | ||
AdditionalFields: { | ||
CustomASIMFormatter: true, | ||
TraceHeaders: {}, | ||
}, | ||
}) | ||
} | ||
) | ||
|
||
const getEventSeverity = (level) => { | ||
return { | ||
debug: 'Informational', | ||
info: 'Informational', | ||
warn: 'Low', | ||
error: 'Medium', | ||
critical: 'High', | ||
}[level] | ||
} | ||
|
||
const loggerConfiguration = { | ||
level: config.logLevel, | ||
transports: [new winston.transports.Console({ colorize: config.isDev })], | ||
}) | ||
} | ||
|
||
if (config.isProd) { | ||
// Only send asim formatted logs on production as other types will mess up processing. | ||
loggerConfiguration.transports = [ | ||
new transports.Console({ | ||
handleExceptions: true, | ||
humanReadableUnhandledException: true, | ||
json: true, | ||
format: format.combine( | ||
winston.format.splat(), | ||
format.simple(), | ||
format.timestamp(), | ||
asimFormat | ||
), | ||
}), | ||
] | ||
} | ||
|
||
const logger = createLogger(loggerConfiguration) | ||
|
||
if (config.isDev) { | ||
logger.exceptions.handle( | ||
new transports.Console({ | ||
format: format.combine(format.timestamp(), format.json()), | ||
}) | ||
) | ||
} | ||
|
||
// Add event types to logger to allow call of constants. | ||
logger.eventTypes = eventTypes | ||
|
||
module.exports = logger |
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
Oops, something went wrong.