Add README with install and usage guide

Signed-off-by: default avatarSnorre Magnus Davøen <snorre.davoen@nsd.uib.no>
parent 8fea89f9
Pipeline #5115 passed with stage
in 21 seconds
# Log Schema Node # Log Schema Node
\ No newline at end of file
This is a Node module intended to make the
[nsd-commons/log-schema](https://gitlab.nsd.uib.no/nsd-commons/log-schema)
consumeable by Node applications. It exposes the
[JSON Schema](http://json-schema.org/) based log schema as a Javascript object,
and a corresponding Typescript definitions file.
## Installation
If you use npm:
```bash
# Add nexus.nsd.no npm repo if not already added:
npm set registry https://nexus.nsd.no/repository/npm-group/
npm install --save @nsd/log-schema-node
```
If you use yarn:
```bash
# Add nexus.nsd.no npm repo if not already added:
npm set registry https://nexus.nsd.no/repository/npm-group/
yarn add @nsd/log-schema-node
```
## Usage
Typescript example below. ES6 would look much the same.
```typescript
import {LogSchema, schema} from "@nsd/log-schema-node";
import * as JaySchema from "jayschema";
const js = new JaySchema();
const logEvent: LogSchema = {
schemaVersion: "v3",
"@timestamp": "1985-04-12T23:20:50.52Z",
levelName: "INFO",
message: "Ørliten melding",
serviceName: "some-service",
serviceVersion: "v1.0.0"
};
console.log(js.validate(logEvent, schema));
```
Currently this package only exposes the schema and the Typescript interface. In
the future it might also provide facilities for validation, etc.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment