Skip to content

Commit 2227022

Browse files
author
Phil Varner
committed
fix morgan middleware request logging
1 parent 0ec88bc commit 2227022

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
### Changed
1515

1616
- Log level must be configured with lowercase values error, warn, info, http, verbose, debug, silly instead of uppercase values (this config had no effect before)
17-
- Search query and response body is now logged at level debug rather than info
18-
- Ingested item body is now logged at level debug rather than info
17+
- Default request logging format is now "tiny" instead of "dev". Previously, the "dev" format
18+
wrote color codes into CloudWatch logs, which cluttered output, as they were not used in display.
19+
- Search query and response body is now logged at level "debug" rather than "info"
20+
- Ingested item body is now logged at level "debug" rather than "info"
1921

2022
## [0.5.2] - 2023-01-17
2123

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ There are some settings that should be reviewed and updated as needeed in the se
404404
| STAC_DOCS_URL | URL to documentation | [https://stac-utils.github.io/stac-server](https://stac-utils.github.io/stac-server) |
405405
| INGEST_BATCH_SIZE | Number of records to ingest in single batch | 500 |
406406
| LOG_LEVEL | Level for logging (error, warn, info, http, verbose, debug, silly) | INFO |
407+
| REQUEST_LOGGING_ENABLED | Express request logging enabled. String 'false' disables. | enabled |
408+
| REQUEST_LOGGING_FORMAT | Express request logging format to use. Any of the [Morgan predefined formats](https://github.com/expressjs/morgan#predefined-formats). | tiny |
407409
| STAC_API_URL | The root endpoint of this API | Inferred from request |
408410
| ENABLE_TRANSACTIONS_EXTENSION | Boolean specifying if the [Transaction Extension](https://github.com/radiantearth/stac-api-spec/tree/master/ogcapi-features/extensions/transaction) should be activated | false |
409411
| STAC_API_ROOTPATH | The path to append to URLs if this is not deployed at the server root. For example, if the server is deployed without a custom domain name, it will have the stage name (e.g., dev) in the path. | "" |

bin/system-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ TEST_PATTERN=${1:-test-*.[jt]s}
77
export AWS_ACCESS_KEY_ID='none'
88
export AWS_SECRET_ACCESS_KEY='none'
99
export ENABLE_TRANSACTIONS_EXTENSION=true
10+
export REQUEST_LOGGING_ENABLED=false
1011

1112
echo "Running tests"
1213
set +e

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"audit-prod": "npx better-npm-audit audit --production",
2020
"deploy": "sls deploy",
2121
"package": "sls package",
22-
"serve": "LOG_LEVEL=debug STAC_API_URL=http://localhost:3000 ENABLE_TRANSACTIONS_EXTENSION=true nodemon ./src/lambdas/api/local.ts",
22+
"serve": "REQUEST_LOGGING_FORMAT=dev LOG_LEVEL=debug STAC_API_URL=http://localhost:3000 ENABLE_TRANSACTIONS_EXTENSION=true nodemon ./src/lambdas/api/local.ts",
2323
"build-api-docs": "npm run widdershins --search false --language_tabs 'nodejs:NodeJS' 'python:Python' --summary ./packages/api-lib/api-spec.yaml -o ./docs/api.md & npm run shins --inline --logo ./docs/images/logo.png -o ./docs/index.html ./docs/api.md"
2424
},
2525
"pre-commit": {

src/lambdas/api/app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ const txnEnabled = process.env['ENABLE_TRANSACTIONS_EXTENSION'] === 'true'
2222

2323
const app = express()
2424

25-
app.use(morgan('dev'))
25+
if (process.env['REQUEST_LOGGING_ENABLED'] !== 'false') {
26+
app.use(morgan(process.env['REQUEST_LOGGING_FORMAT'] || 'tiny'))
27+
}
28+
2629
app.use(cors())
2730
app.use(express.json({ limit: '1mb' }))
2831
app.use(addEndpoint)

0 commit comments

Comments
 (0)