Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
OX App Suite
Core
ui-middleware
Commits
2242cca6
Commit
2242cca6
authored
3 years ago
by
richard.petersen
Committed by
julian.baeume
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Environment variables for logging are not respected and prevent service from starting
parent
979acc74
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/createApp.js
+4
-2
4 additions, 2 deletions
src/createApp.js
src/index.js
+2
-2
2 additions, 2 deletions
src/index.js
src/logger.js
+11
-3
11 additions, 3 deletions
src/logger.js
with
17 additions
and
7 deletions
src/createApp.js
+
4
−
2
View file @
2242cca6
...
...
@@ -6,7 +6,7 @@ import express from 'express'
import
helmet
from
'
helmet
'
// Fastest HTTP logger for Node.js in town
import
{
l
ogger
}
from
'
./logger.js
'
import
{
getL
ogger
}
from
'
./logger.js
'
import
pinoHttp
from
'
pino-http
'
// Readiness and liveness checks middleware
import
health
from
'
@cloudnative/health-connect
'
...
...
@@ -21,7 +21,6 @@ import fs from 'fs'
import
{
getDependencies
,
getOxManifests
}
from
'
./manifests.js
'
const
ignorePaths
=
[
'
/ready
'
,
'
/healthy
'
]
const
httpLogger
=
pinoHttp
({
logger
,
autoLogging
:
{
ignorePaths
}
})
const
swaggerDocument
=
yaml
.
load
(
fs
.
readFileSync
(
'
./src/swagger.yaml
'
,
'
utf8
'
))
const
bypass
=
(
request
)
=>
ignorePaths
.
includes
(
request
.
path
)
const
metricsMiddleware
=
promBundle
({
bypass
})
...
...
@@ -31,6 +30,9 @@ export function createApp () {
const
app
=
express
()
const
logger
=
getLogger
()
const
httpLogger
=
pinoHttp
({
logger
,
autoLogging
:
{
ignorePaths
}
})
const
healthCheck
=
new
health
.
HealthChecker
()
// Application-level middleware
...
...
This diff is collapsed.
Click to expand it.
src/index.js
+
2
−
2
View file @
2242cca6
// Add env vars from files
// Note: actual env vars supersede .env file and .env file supersedes .env.defaults file
import
{
config
}
from
'
dotenv-defaults
'
import
{
l
ogger
}
from
'
./logger.js
'
import
{
getL
ogger
}
from
'
./logger.js
'
import
{
createApp
}
from
'
./createApp.js
'
config
()
...
...
@@ -10,5 +10,5 @@ const app = createApp()
// Binds and listens for connections on the specified host and port
app
.
listen
(
process
.
env
.
PORT
,
()
=>
{
l
ogger
.
info
(
`manifest-service listening on port
${
process
.
env
.
PORT
}
`
)
getL
ogger
()
.
info
(
`manifest-service listening on port
${
process
.
env
.
PORT
}
`
)
})
This diff is collapsed.
Click to expand it.
src/logger.js
+
11
−
3
View file @
2242cca6
// Very low overhead Node.js logger. Logs in json use pino-pretty for dev.
import
Logger
from
'
pino
'
export
const
logger
=
new
Logger
({
level
:
process
.
env
.
LOG_LEVEL
})
export
const
getLogger
=
(()
=>
{
let
logger
return
function
getLogger
()
{
if
(
!
logger
)
{
logger
=
new
Logger
({
level
:
process
.
env
.
LOG_LEVEL
})
}
return
logger
}
})()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment