@samtec-ash/cloudlogging
v0.1.0
Published
Cloud remote logging service to AWS CloudWatch
Downloads
9
Keywords
Readme
Cloud Logging
Overview
CloudWatch Logging is used to push logs to AWS CloudWatch.
The logging service logs to two transports Console (stdout/stderr) and CloudWatch. There are 5 levels of logs:
- error ( highest )
- warn
- info
- debug
- silly ( lowest )
By default, Console transport will be used for levels debug and up with debug and error going to stderr.
By default, CloudWatch transport will be used for levels info and up.
Development
Building
yarn run prepublish
Usage
Prerequisites
# Install AWS cli
pip install awscli --upgrade --user
# Configure AWS
## Method 1: Prompt to create .aws file
aws configure
## Method 2: No Prompt to create .aws file
echo -ne '
[default]
aws_access_key_id = AWS_ACCESS_KEY_ID
aws_secret_access_key = AWS_SECRET_ACCESS_KEY
' > ~/.aws/credentials
echo -ne '
[default]
region = us-east-2
output = json
' > ~/.aws/config
## Method 3: No Prompt to set as env variables
export AWS_ACCESS_KEY_ID="AWS_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="AWS_SECRET_ACCESS_KEY"
Installation
# Add package to project
yarn add @samtec-ash/virtuinlogging
Example
es2016 w/ Async/await :
import { CloudLogger } from '@samtec-ash/CloudLogging';
const logger = new CloudLogger('groupName');
const streamName: {String} = ...;
let success;
if (await logger.open(streamName)) {
success = await logger.log('Connected to CloudWatch Logs!', 'info');
success = await logger.log('Some warning message', 'warn');
const status = logger.status();
logger.clear();
success = await logger.close();
console.log("Done!");
}
API
The autogenerated API can be accessed in following mediums:
Publishing
New versions are published to npmjs.com. BitBucket Pipelines is used to build, test, stage, & deploy. Refer to the pipeline configuration.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Adam Page
- Nathan Page
License
This project is licensed under the MIT License - see the LICENSE.md file for details