https://github.com/architect/logs
manage @architect Function logs
https://github.com/architect/logs
Last synced: about 1 year ago
JSON representation
manage @architect Function logs
- Host: GitHub
- URL: https://github.com/architect/logs
- Owner: architect
- License: apache-2.0
- Created: 2019-07-08T21:20:57.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-30T15:58:53.000Z (about 2 years ago)
- Last Synced: 2024-11-08T12:06:25.062Z (over 1 year ago)
- Language: JavaScript
- Size: 541 KB
- Stars: 4
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: .github/contributing.md
- License: LICENSE
- Code of conduct: .github/code_of_conduct.md
Awesome Lists containing this project
README
# `@architect/logs` [](https://github.com/architect/logs/actions?query=workflow%3A%22Node+CI%22)
[@architect/logs][npm] is a module that retrieves and clears logs associated to
your @architect functions across environments.
## Installation
npm i @architect/logs
let logs = require('@architect/logs')
# API
## `logs({pathToCode, verbose, destroy, production}, callback)`
Takes a parameter object as first argument which accepts the following properties:
- `pathToCode`: **required** the local path to architect Function code relative
to the current working directory, i.e. `src/http/get-index`
- `verbose`: verbose super chatty mode
- `destroy`: if truthy will delete logs via [`logs.destroy`][destroy], otherwise will
read logs via [`logs.read`][read]
- `production`: if truthy will target your arc project's production environment,
otherwise will default to staging
By default will [read][read] logs from the staging environment. If the `destroy`
property is truthy, logs instead will be [destroyed][destroy].
## `logs.read({name, pathToCode, ts}, callback)`
Will read logs from [`aws.CloudWatchLogs`][cloudwatchlogs], invoking
[`getLogEvents`][getlogevents] for log retrieval.
Takes a parameter object as first argument which accepts the following properties:
- `name`: the CloudFormation `StackName` passed to
[`listStackResources`][liststack] within which to search Function logs. Note
that this is inferred from your application name, environment and specific
function you are querying - tread carefully!
- `pathToCode`: **required** the local path to architect Function code relative
to the current working directory, i.e. `src/http/get-index`
- `ts`: timestamp to use as a start time for displaying length of time details
(i.e. `Date.now()`)
`callback` will be invoked with an error if an error arises during execution.
Otherwise, `callback` will be invoked without arguments.
## `logs.destroy({name, pathToCode, ts}, callback)`
Will delete logs from [`aws.CloudWatchLogs`][cloudwatchlogs], invoking
[`deleteLogGroup`][deleteloggroup].
Takes a parameter object as first argument which accepts the following properties:
- `name`: the CloudFormation `StackName` passed to
[`listStackResources`][liststack] within which to search Function logs. Note
that this is inferred from your application name, environment and specific
function you are querying - tread carefully!
- `pathToCode`: **required** the local path to architect Function code relative
to the current working directory, i.e. `src/http/get-index`
- `ts`: timestamp to use as a start time for displaying length of time details
(i.e. `Date.now()`)
`callback` will be invoked with an error if an error arises during execution.
Otherwise, `callback` will be invoked without arguments.
[npm]: https://www.npmjs.com/package/@architect/logs
[read]: #logsreadname-pathtocode-ts-callback
[destroy]: #logsdestroyname-pathtocode-ts-callback
[liststack]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFormation.html#listStackResources-property
[cloudwatchlogs]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html
[getlogevents]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html#getLogEvents-property
[deleteloggroup]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html#deleteLogGroup-property