Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
log-schema-node
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
logging
log-schema-node
Commits
f5eba72d
Unverified
Commit
f5eba72d
authored
May 10, 2017
by
Snorre Magnus Davøen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add README with install and usage guide
Signed-off-by:
Snorre Magnus Davøen
<
snorre.davoen@nsd.uib.no
>
parent
8fea89f9
Pipeline
#5115
passed with stage
in 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletion
+48
-1
README.md
README.md
+48
-1
No files found.
README.md
View file @
f5eba72d
# Log Schema Node
\ No newline at end of file
# Log Schema Node
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.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment