Path: blob/master/src/SentinelUtilities/SentinelLog/log.py
3255 views
# -------------------------------------------------------------------------1# Copyright (c) Microsoft Corporation. All rights reserved.2# Licensed under the MIT License. See License.txt in the project root for3# license information.4# --------------------------------------------------------------------------5"""6log module:7This module provides log functionalities through Azure Application Insights8"""91011from applicationinsights import TelemetryClient12from SentinelUtils.obfuscation_utility import ObfuscationUtility131415class Log:16""" The class performs log action """1718def __init__(self):19self.seed = b'IVnGT69i43R1i6qokpVxIx_tE2MyBlMebu4yJfJh1Ow='20# pylint: disable=line-too-long21self.ai_code = b'gAAAAABdN3UmwZJHHxTybj0KRbKNehSo55DZ5Bi2QtohQsrEgy-WZNWDQAETVnaeJbQ4S0ltZLkebi_hhueaxl_uxYE5HheuB0ZFobq1IzgE163jUsjSLqilcqzy_uLKkSTYHAxYNLxL'2223def log(self, telemetry_instance):24""" Log Telemetry instance """2526obfuscate = ObfuscationUtility(self.seed)27client = TelemetryClient(obfuscate.deobfuscate_text(self.ai_code))28client.track_trace(str(telemetry_instance))29client.flush()3031def log_event(self, message):32""" Log simple message in strinbg """3334obfuscate = ObfuscationUtility(self.seed)35client = TelemetryClient(obfuscate.deobfuscate_text(self.ai_code))36client.track_event(message)37client.flush()383940