-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add messageTypeId and messageTsUs proprties only if they exist. (#30)
* Add messageTypeId and messageTsUs proprties only if they exist. * Always convert message type id to string * Remove pid property from parsed message * Address comments * Add tests for log formatting * Add format tests. Update deps
- Loading branch information
kkuzmin
authored
Apr 24, 2019
1 parent
de14472
commit 9e55c93
Showing
5 changed files
with
98 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const assert = require('assert'); | ||
const formatLog = require('../EHubGeneral/format').logRecord; | ||
const mock = require('./mock'); | ||
|
||
describe('Format log units', function(){ | ||
it('Formats log record correctly, no optional properties', function(done){ | ||
let logRecord = Object.assign({}, mock.SQL_AUDIT_LOG_RECORD); | ||
delete logRecord.operationName; | ||
delete logRecord.category; | ||
logRecord.time = "2018-12-10T00:03:46Z"; | ||
const formattedRecord = formatLog(logRecord); | ||
|
||
const expectedRecord = { | ||
messageTs: 1544400226, | ||
priority: 11, | ||
progName: 'EHubGeneral', | ||
message: JSON.stringify(logRecord), | ||
messageType: 'json/azure.ehub' | ||
}; | ||
|
||
assert.deepEqual(formattedRecord, expectedRecord); | ||
done(); | ||
}); | ||
|
||
it('Formats log record correctly, with optional properties', function(done){ | ||
let logRecord = Object.assign({}, mock.ACTIVITY_LOG_RECORD); | ||
logRecord.eventTimestamp = "2018-03-21T17:00:32.125Z"; | ||
const formattedRecord = formatLog(logRecord); | ||
|
||
const expectedRecord = { | ||
messageTs: 1521651632, | ||
priority: 11, | ||
progName: 'EHubGeneral', | ||
message: JSON.stringify(logRecord), | ||
messageType: 'json/azure.ehub', | ||
messageTypeId: `${logRecord.category.value}`, | ||
messageTsUs: 125000 | ||
}; | ||
|
||
assert.deepEqual(formattedRecord, expectedRecord); | ||
done(); | ||
}); | ||
|
||
it('Formats log record correctly, with message type id of Zero', function(done){ | ||
let logRecord = Object.assign({}, mock.AUDIT_LOG_RECORD); | ||
logRecord.time = "2018-03-21T17:00:32.125Z"; | ||
logRecord.category = 0; | ||
const formattedRecord = formatLog(logRecord); | ||
|
||
const expectedRecord = { | ||
messageTs: 1521651632, | ||
priority: 11, | ||
progName: 'EHubGeneral', | ||
message: JSON.stringify(logRecord), | ||
messageType: 'json/azure.ehub', | ||
messageTypeId: '0', | ||
messageTsUs: 125000 | ||
}; | ||
|
||
assert.deepEqual(formattedRecord, expectedRecord); | ||
done(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.