Skip to content

Commit

Permalink
feat(ogma): creates Ogma module for NestJS usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcdo29 committed Dec 15, 2019
0 parents commit 3afc562
Show file tree
Hide file tree
Showing 18 changed files with 13,257 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
pull_request:
branches:
- 'master'
push:
branches:
- '*'
schedule:
- cron: '0 0 * * *'

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: npm ci
- name: check format
run: npx prettier --check 'src/**/*.ts'
- name: lint
run: npm run lint
- name: npm test
run: npm run test:cov
- name: npm build
run: npm run build
env:
CI: true
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*

*.tgz
16 changes: 16 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"singleQuote": true,
"arrowParens": "always",
"trailingComma": "all",
"overrides": [
{
"files": "*.md",
"options": {
"printWidth": 70,
"useTabs": false,
"trailingComma": "none",
"proseWrap": "never"
}
}
]
}
Empty file added .sonarcloud.properties
Empty file.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div align="center">

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jmcdo29_nestjs-ogma&metric=alert_status)](https://sonarcloud.io/dashboard?id=jmcdo29_ogma) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![Actions Status](https://github.com/jmcdo29/nestjs-ogma/workflows/CI/badge.svg)](https://github.com/jmcdo29/nestjs-ogma/workflows/CI/badge.svg)

</div>

# nestjs-ogma

A [NestJS module](https://docs.nestjs.com) for the [Ogma](https://github.com/jmcdo29/ogma) logging package.

## Usage

The OgmaService class is TRANSIENT scoped, which means that for each time you call `OgmaModule.forFeature()` a new instance of the `OgmaService` is created, and a new context is given to that OgmaService if one is provided. The base Ogma class, will also be created as you are able to pass in options for the ogma class. This allows you to give each of your OgmaService's different logLevel configurations, which can be a big win.

Ogma is a lightweight logger with customization options, that prints your logs in a pretty manner with timestamping, colors, and different levels. See the GitHub repository for Ogma to learn more about configuration and options.

## Configuration

Currently, configuration is only done in the `forFeature` static method of the module. The method takes in a single object that is an intersection of the context key, and the `OgmaOptions` from the `Ogma` package. You could configured your OgmaModule like so

```ts
@Module({
imports: [
OgmaModule.forFeature({ context: MyService.name, color: false })
],
providers: [MyService]
})
export class MyModule {}
```

The above will turn colors off for MyModule's related service's logs, and will create a context for the logs called 'MyService`.
23 changes: 23 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'build',
'ci',
'chore',
'revert',
'feat',
'fix',
'improvement',
'docs',
'style',
'refactor',
'perf',
'test',
],
],
},
};
4 changes: 4 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
Loading

0 comments on commit 3afc562

Please sign in to comment.