@cumulus/logger
A logging library for use on the Cumulus project.
The @cumulus/logger
library exports a Logger
class, which generates
JSON-formated log events.
Log events always have the following keys:
- level (string) - the priority level of the message
- message (string) - the message itself
- sender (string) - the resource that created the message
- timestamp (string) - an ISO-8601 timestamp
Log events may have the following options keys:
- executions (string)
- granules (string [stringified array of objects])
- parentArn (string)
- stackName (string)
- version (string)
- asyncOperationId (string)
Log events may also contain user-specified keys.
Example log event:
{
"level": "info",
"message": "hello world",
"sender": "greetingFunction",
"timestamp": "2018-10-19T19:12:47.501Z"
}
Install
npm install @cumulus/logger
Usage
const Logger = require('@cumulus/logger');
const log = new Logger({ sender: 'example' });
log.info('hello, world');
API
new Logger({ [asyncOperationId], [executions], [granules], [parentArn], [sender], [stackName], [version] })
asyncOperationId
Type: string
An optional async operation id associated with a workflow.
executions
Type: string
An optional description of the executions.
granules
type: string
An optional granules string. Generally a stringified array of granule objects.
parentArn
type: string
An optional stepfunction ARN of the parent workflow that triggered the current execution.
sender
Type: string
The sender of the log event. Typically a Lambda Function Name or ECS Task Name.
Defaults to "unknown".
stackName
type: string
Cumulus stack name.
version
Type: string
An optional version.
log.debug([...messageArgs])
Writes a log event to stdout with level set to "debug".
args
Type: ...any
See console.log().
log.error([...messageArgs][, error])
Writes a log event to stderr with level set to "error".
args
Type: ...any
See console.log().
error
Type: Error
If the last argument is an Error then the following additional properties will be set on the log event:
- error (Object)
- name (string)
- message (string)
- stack (Array<string>) - the lines of the stack trace
log.fatal([...messageArgs])
Writes a log event to stdout with level set to "fatal".
args
Type: ...any
See console.log().
log.info([...messageArgs])
Writes a log event to stdout with level set to "info".
args
Type: ...any
See console.log().
log.infoWithAdditionalKeys(additionalKeys, ...messageArgs)
Writes a log event to stdout with level set to "info". In addition to the
standard keys, additional keys will be added to the event. If an additional key
is specified with the same name as a standard key, the value standard key will
be displayed.
additionalKeys
Type: Object
Additional key/value pairs to be added to the event.
args
Type: ...any
See console.log().
log.trace([...messageArgs])
Writes a log event to stdout with level set to "trace".
args
Type: ...any
See console.log().
log.warn([...messageArgs])
Writes a log event to stdout with level set to "debug".
args
Type: ...any
See console.log().
About Cumulus
Cumulus is a cloud-based data ingest, archive, distribution and management
prototype for NASA's future Earth science data streams.
Cumulus Documentation
Contributing
To make a contribution, please see our contributing guidelines.
[v18.4.0] 2024-08-16
Migration Notes
CUMULUS-3320 Update executions table
The work for CUMULUS-3320 required index updates as well as a modification of a
table constraint. To install the update containing these changes you should:
- Pre-generate the indexes on the execution table. This can be done via manual
procedure prior to upgrading without downtime, or done more quickly before or
during upgrade with downtime.
- Update the
executions_parent_cumulus_id_foreign
constraint. This will
require downtime as updating the constraint requires a table write lock, and
the update may take some time.
Deployments with low volume databases and low activity and/or test/development
environments should be able to install these updates via the normal automatic
Cumulus deployment process.
Please carefully review the migration process documentation. Failure to
make these updates properly will likely result in deployment failure and/or
degraded execution table operations.
CUMULUS-3449 Please follow the instructions before upgrading Cumulus
Breaking Changes
Added
- CUMULUS-3320
- Added endpoint
/executions/bulkDeleteExecutionsByCollection
to allow
bulk deletion of executions from elasticsearch by collectionId - Added
Bulk Execution Delete
migration type to async operations types
- CUMULUS-3608
- Exposes variables for sqs_message_consumer_watcher messageLimit and timeLimit configurations. Descriptions
of the variables here include notes on usage and what users should
consider if configuring something other than the default values.
- CUMULUS-3449
- Updated the following database columns to BIGINT: executions.cumulus_id, executions.parent_cumulus_id,
files.granule_cumulus_id, granules_executions.granule_cumulus_id, granules_executions.execution_cumulus_id
and pdrs.execution_cumulus_id
- Changed granules table unique constraint to granules_collection_cumulus_id_granule_id_unique
- Added indexes granules_granule_id_index and granules_provider_collection_cumulus_id_granule_id_index
to granules table
Changed
- CUMULUS-3320
- Updated executions table (please see Migration section and Upgrade
Instructions for more information) to:
- Add index on
collection_cumulus_id
- Add index on
parent_cumulus_id
- Update
executions_parent_cumulus_id_foreign
constraint to add ON DELETE SET NULL
. This change will cause deletions in the execution table to
allow deletion of parent executions, when this occurs the child will have
it's parent reference set to NULL as part of the deletion operations.
- CUMULUS-3449
- Updated
@cumulus/db
package and configure knex hook postProcessResponse to convert the return string
from columns ending with "cumulus_id" to number.
- CUMULUS-3841
- Increased
fetchRules
page size to default to 100 instead of 10. This improves overall query time when
fetching all rules such as in sqsMessageConsumer
.
Fixed
- CUMULUS-3817
- updated applicable @aws-sdk dependencies to 3.621.0 to remove inherited vulnerability from fast-xml-parser
- CUMULUS-3320
- Execution database deletions by
cumulus_id
should have greatly improved
performance as a table scan will no longer be required for each record
deletion to validate parent-child relationships
- CUMULUS-3818
- Fixes default value (updated to tag 52) for async-operation-image in tf-modules/cumulus.
- CUMULUS-3840
- Fixed
@cumulus/api/bin/serve
to correctly use EsClient.