55
66const { app, InvocationContext } = require ( '@azure/functions' ) ;
77
8- const VERSION = '1.2.1 ' ;
8+ const VERSION = '2.0.0 ' ;
99
1010const STRING = 'string' ; // example: 'some message'
1111const STRING_ARRAY = 'string-array' ; // example: ['one message', 'two message', ...]
@@ -181,7 +181,7 @@ class HTTPClient {
181181 try {
182182 return await this . send ( batch ) ;
183183 } catch ( e ) {
184- this . context . log . error ( e ) ;
184+ this . context . error ( e ) ;
185185 }
186186 } )
187187 ) ;
@@ -204,7 +204,7 @@ class HTTPClient {
204204 if ( retries === 0 ) {
205205 throw new Error ( errMsg ) ;
206206 }
207- this . context . log . warn (
207+ this . context . warn (
208208 `Unable to send request, with error: ${ errMsg } . Retrying ${ retries } more times`
209209 ) ;
210210 retries -- ;
@@ -259,7 +259,7 @@ class Scrubber {
259259 )
260260 ) ;
261261 } catch {
262- context . log . error (
262+ context . error (
263263 `Regexp for rule ${ name } pattern ${ settings [ 'pattern' ] } is malformed, skipping. Please update the pattern for this rule to be applied.`
264264 ) ;
265265 }
@@ -414,10 +414,10 @@ class EventhubLogHandler {
414414 this . handleJSONArrayLogs ( logs , JSON_STRING_ARRAY ) ;
415415 break ;
416416 case INVALID :
417- this . context . log . error ( 'Log format is invalid: ' , logs ) ;
417+ this . context . error ( 'Log format is invalid: ' , logs ) ;
418418 break ;
419419 default :
420- this . context . log . error ( 'Log format is invalid: ' , logs ) ;
420+ this . context . error ( 'Log format is invalid: ' , logs ) ;
421421 break ;
422422 }
423423 return this . records ;
@@ -429,7 +429,7 @@ class EventhubLogHandler {
429429 try {
430430 message = JSON . parse ( message ) ;
431431 } catch {
432- this . context . log . warn (
432+ this . context . warn (
433433 'log is malformed json, sending as string'
434434 ) ;
435435 this . formatLog ( STRING_TYPE , message ) ;
@@ -441,7 +441,7 @@ class EventhubLogHandler {
441441 try {
442442 message = JSON . parse ( message . toString ( ) ) ;
443443 } catch {
444- this . context . log . warn (
444+ this . context . warn (
445445 'log is malformed json, sending as string'
446446 ) ;
447447 this . formatLog ( STRING_TYPE , message . toString ( ) ) ;
@@ -656,7 +656,7 @@ app.eventHub('datadog-function', {
656656 cardinality : 'many' ,
657657 handler : async ( eventHubMessages , context ) => {
658658 if ( ! DD_API_KEY || DD_API_KEY === '<DATADOG_API_KEY>' ) {
659- context . log . error (
659+ context . error (
660660 'You must configure your API key before starting this function (see ## Parameters section)'
661661 ) ;
662662 return ;
@@ -666,13 +666,13 @@ app.eventHub('datadog-function', {
666666 let handler = new EventhubLogHandler ( context ) ;
667667 parsedLogs = handler . handleLogs ( eventHubMessages ) ;
668668 } catch ( err ) {
669- context . log . error ( 'Error raised when parsing logs: ' , err ) ;
669+ context . error ( 'Error raised when parsing logs: ' , err ) ;
670670 throw err ;
671671 }
672672 let results = await new HTTPClient ( context ) . sendAll ( parsedLogs ) ;
673673
674674 if ( results . every ( v => v === true ) !== true ) {
675- context . log . error (
675+ context . error (
676676 'Some messages were unable to be sent. See other logs for details.'
677677 ) ;
678678 }
0 commit comments