dl-commons 0.0.2-testing.38 → 0.0.2-testing.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ export declare class Logger {
2
+ private _isGraylog;
3
+ private _host;
4
+ private _port;
5
+ private _hostname;
6
+ private _facility;
7
+ constructor(host: string, port: number, hostname: string, facility: string, isGraylog?: boolean);
8
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ const gelf_pro_1 = require("gelf-pro");
5
+ class Logger {
6
+ constructor(host, port, hostname, facility, isGraylog = false) {
7
+ this._isGraylog = isGraylog;
8
+ if (this._isGraylog) {
9
+ gelf_pro_1.default.setConfig({
10
+ adapterName: 'udp',
11
+ adapterOptions: {
12
+ host,
13
+ port,
14
+ },
15
+ fields: { facility, hostname },
16
+ });
17
+ }
18
+ }
19
+ }
20
+ exports.Logger = Logger;
21
+ //# sourceMappingURL=logger.class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.class.js","sourceRoot":"","sources":["../../src/utils/logger.class.ts"],"names":[],"mappings":";;;AAAA,uCAA4B;AAE5B,MAAa,MAAM;IASf,YAAY,IAAY,EAAE,IAAY,EAAE,QAAgB,EAAE,QAAgB,EAAE,YAAqB,KAAK;QAClG,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,kBAAI,CAAC,SAAS,CAAC;gBACX,WAAW,EAAE,KAAK;gBAClB,cAAc,EAAE;oBACZ,IAAI;oBACJ,IAAI;iBACP;gBACD,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;aACjC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ;AAvBD,wBAuBC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dl-commons",
3
3
  "type": "commonjs",
4
- "version": "0.0.2-testing.38",
4
+ "version": "0.0.2-testing.39",
5
5
  "description": "distance learning commons",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { ConfigService } from '@nestjs/config';
3
- import gelf from 'gelf-pro';
3
+ const gelf = require('gelf-pro');
4
4
 
5
5
  @Injectable()
6
6
  export class AppLoggerService {
@@ -0,0 +1,26 @@
1
+ import gelf from 'gelf-pro';
2
+
3
+ export class Logger {
4
+ //#region Private Members
5
+ private _isGraylog: boolean;
6
+ private _host: string;
7
+ private _port: number;
8
+ private _hostname: string;
9
+ private _facility: string;
10
+ //#endregion
11
+
12
+ constructor(host: string, port: number, hostname: string, facility: string, isGraylog: boolean = false) {
13
+ this._isGraylog = isGraylog;
14
+
15
+ if (this._isGraylog) {
16
+ gelf.setConfig({
17
+ adapterName: 'udp',
18
+ adapterOptions: {
19
+ host,
20
+ port,
21
+ },
22
+ fields: { facility, hostname },
23
+ });
24
+ }
25
+ }
26
+ }