huridocs/uwazi

View on GitHub
app/api/log.v2/infrastructure/writers/StandardJSONWriter.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { LogEntry } from '../LogEntry';
import { LogWriter } from '../LogWriter';

export const StandardJSONWriter: LogWriter = (log: LogEntry) => {
  process.stdout.write(
    `${JSON.stringify({
      time: log.timeToString(),
      level: log.level.name,
      tenant: log.tenant.name,
      message: log.message,
    })}\n`
  );
};

export const UwaziJSONWriter: LogWriter = (log: LogEntry) => {
  process.stdout.write(
    `${JSON.stringify({
      time: log.timeToString(),
      level: log.level.name,
      tenant: log.tenant.name,
      message: log.message,
      application_name: 'Uwazi',
    })}\n`
  );
};