Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Azure
GitHub Repository: Azure/Azure-Sentinel-Notebooks
Path: blob/master/src/SentinelUtilities/SentinelLog/log.py
3255 views
1
# -------------------------------------------------------------------------
2
# Copyright (c) Microsoft Corporation. All rights reserved.
3
# Licensed under the MIT License. See License.txt in the project root for
4
# license information.
5
# --------------------------------------------------------------------------
6
"""
7
log module:
8
This module provides log functionalities through Azure Application Insights
9
"""
10
11
12
from applicationinsights import TelemetryClient
13
from SentinelUtils.obfuscation_utility import ObfuscationUtility
14
15
16
class Log:
17
""" The class performs log action """
18
19
def __init__(self):
20
self.seed = b'IVnGT69i43R1i6qokpVxIx_tE2MyBlMebu4yJfJh1Ow='
21
# pylint: disable=line-too-long
22
self.ai_code = b'gAAAAABdN3UmwZJHHxTybj0KRbKNehSo55DZ5Bi2QtohQsrEgy-WZNWDQAETVnaeJbQ4S0ltZLkebi_hhueaxl_uxYE5HheuB0ZFobq1IzgE163jUsjSLqilcqzy_uLKkSTYHAxYNLxL'
23
24
def log(self, telemetry_instance):
25
""" Log Telemetry instance """
26
27
obfuscate = ObfuscationUtility(self.seed)
28
client = TelemetryClient(obfuscate.deobfuscate_text(self.ai_code))
29
client.track_trace(str(telemetry_instance))
30
client.flush()
31
32
def log_event(self, message):
33
""" Log simple message in strinbg """
34
35
obfuscate = ObfuscationUtility(self.seed)
36
client = TelemetryClient(obfuscate.deobfuscate_text(self.ai_code))
37
client.track_event(message)
38
client.flush()
39
40