@@ -123,14 +123,16 @@ declare interface Logger {
123123export default class Rootle {
124124 private id : string ;
125125 private application : string ;
126+ private event ?: string ;
126127
127- constructor ( id : string , application : string ) {
128+ constructor ( id : string , application : string , event ?: string ) {
128129 this . id = id ;
129130 this . application = application ;
131+ this . event = event ;
130132 }
131133
132134 // @ts -ignore
133- private logMessage ( message : string , level : string , event ?: string , downstream ?: Downstream , stackTrace ?: string , code ?: number , callback : Logger ) {
135+ private logMessage ( message : string , level : string , downstream ?: Downstream , stackTrace ?: string , code ?: number , callback : Logger ) {
134136 const log : Log = {
135137 id : this . id ,
136138 application : this . application ,
@@ -139,7 +141,7 @@ export default class Rootle {
139141 level : level
140142 } ;
141143 if ( level === "ERROR" ) {
142- log . event = event ;
144+ log . event = this . event ;
143145 log . downstream = downstream ;
144146 log . stackTrace = stackTrace ;
145147 log . code = code ;
@@ -149,22 +151,25 @@ export default class Rootle {
149151
150152 }
151153 public info ( message : string ) {
152- this . logMessage ( message , "INFO" , undefined , undefined , undefined , undefined , ( logJson ) => {
154+ this . logMessage ( message , "INFO" , undefined , undefined , undefined , ( logJson ) => {
153155 console . log ( logJson ) ;
154156 } ) ;
155157 }
156158
157159 public warn ( message : string ) {
158- this . logMessage ( message , "WARN" , undefined , undefined , undefined , undefined , ( logJson ) => {
160+ this . logMessage ( message , "WARN" , undefined , undefined , undefined , ( logJson ) => {
159161 console . log ( logJson ) ;
160162 } ) ;
161163 }
162164
163- public error ( message : string , event ?: string , downstream ?: Downstream , stackTrace ?: string , code ?: number ) {
164- this . logMessage ( message , "ERROR" , event , downstream , stackTrace , code , ( logJson ) => {
165+ public error ( message : string , downstream ?: Downstream , stackTrace ?: string , code ?: number ) {
166+ this . logMessage ( message , "ERROR" , downstream , stackTrace , code , ( logJson ) => {
165167 console . log ( logJson ) ;
166168 } ) ;
167169 }
168170
171+ public setEvent ( event : string ) {
172+ this . event = event ;
173+ }
169174
170175}
0 commit comments