You can add multiple schemas for the logging data by adding a custom file model.<yourmodel>.jsonto the models directory.
{
    "eventName": "Name",
    "timestamp": 123,
    "eventId": 1
}- POST /log/:schema- post a log to the server for a logging schema (protected by access token)
- GET /display/:schema- display the current logging data for a logging schema
- GET /schema/:schema- display the selected schema for JSON logs
- GET /export/:schema- export data to a CSV file for a logging schema
See: express-access-token
curl -X POST -H "Authorization: Bearer <your_token>" -H "Content-Type: application/json" -d '{"eventName": "This is another test log message", "timestamp": "223123"}' http://localhost:3000/log/config import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { isDevMode } from '@angular/core';
import { take } from 'rxjs';
export class Logging {
  constructor(public http: HttpClient) {}
  sendData(data: any) { // data must be flat JSON object without arrays
    const headers = new HttpHeaders({
      'Content-Type': 'application/json',
      'Accept': 'application/json',
      'Authorization': 'Bearer <your_token>'
    });
    const url = isDevMode()
      ? 'http://<local_logging_server>:<port>/log/<your_schema>'
      : 'http://<production_logging_server>:<port>/log/<your_schema>';
    this.http
      .post(url, data, { headers: headers })
      .pipe(take(1))
      .subscribe({
        complete: () => { console.log('Logging Success'); },
        error: (err: HttpErrorResponse) => {
          if (err.error instanceof Error) {
              console.log('Client-side error occured.');
          } else {
              console.log('Server-side error occured.');
              console.log(err.error);
          }
        }
      });
  }
}Build and run with docker-compose and shut down node container, run app locally from development environenmt using npm start.
git clone https://github.com/visualengineers/smallloggingserver-node.git
ENV="production" ACCESS_TOKEN="your_token" docker compose up -d --buildFor Powershell use:
$env:ACCESS_TOKEN='123'
$env:ENV='production'
docker-compose up -d --buildRun Mongo shell in your container:
docker exec -it <container_id> mongoshQuery your data in mongo shell:
show dbs
use eventLogs
show tables
db.yourschema.find()
db['<yourschema>'].find()
db.yourschema.deleteMany({})
exit
To reset and delete all schemas do
use eventLogs
db.dropDatabase();