Installation
$ npm i @crasman/cloud-logger
Permissions
Writing logs into GCP requires the roles/logging.logWriter
role.
Usage
import { CloudLogger } from '@crasman/cloud-logger';
const { logger } = new CloudLogger({ projectId: 'your-gcp-project-id' });
logger.info('Cloud logger initialized.', { hello: 'world' });
Logger methods
All logging methods take a message
argument, and optionally any number of metadata arguments.
-
emergency()
- Panic condition, affects multiple services. Notify all tech staff -
alert()
- Requires immediate attention. Notify staff who can fix the problem -
critical()
- Indicates failure in a primary system. Fix critical problems before alert -
error()
- Failure, does not require immediate attention. Notify developers or admins -
warning()
- Indicates a potential error which may escalate if not fixed. Notify developers -
notice()
- Indicates an unusual event, which is not an error. No immediate action required -
info()
- Normal operational messages. No action required -
debug()
- Debugging traces.
Developing/publishing
- Before pushing changes to
main
, remember tonpm run build
first. - Please use conventional commits:
-
feat:
New feature for users -
fix:
Fix a bug for users -
docs:
Changes to documentation -
style:
Changes to code formatting -
refactor:
Refactoring production code -
test:
Adding or refactoring tests -
chore:
Updating build automation etc. -
BREAKING CHANGE
New major version
-