add log support
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
import logging
|
||||
|
||||
|
||||
def init_logger():
|
||||
logging.basicConfig(filename="appointment.log",
|
||||
filemode='a',
|
||||
format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
|
||||
datefmt='%D:%H:%M:%S',
|
||||
level=logging.INFO)
|
||||
@@ -1,44 +0,0 @@
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import oci
|
||||
from oci.loggingingestion import LoggingClient
|
||||
from oci.loggingingestion.models import PutLogsDetails, LogEntryBatch, LogEntry
|
||||
|
||||
from utils.AppLogging import init_logger
|
||||
|
||||
|
||||
class LogSender:
|
||||
def __init__(self):
|
||||
self._config = oci.config.from_file("~/.oci/logger_config")
|
||||
self._identity = oci.identity.IdentityClient(self._config)
|
||||
self._loggingingestion_client = LoggingClient(self._config)
|
||||
|
||||
def send_log(self, msg: str, subject="appointment", type: str = "INFO"):
|
||||
log_id = "ocid1.log.oc1.eu-frankfurt-1.amaaaaaacvc3jtia5enufv5jxe6binq4ndaty7pt5mk7uidipfd62ynwdhnq"
|
||||
response = self._loggingingestion_client.put_logs(
|
||||
log_id=log_id,
|
||||
put_logs_details=PutLogsDetails(
|
||||
specversion="1.0",
|
||||
log_entry_batches=[
|
||||
LogEntryBatch(
|
||||
entries=[LogEntry(
|
||||
data=msg,
|
||||
id=log_id,
|
||||
time=datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"))],
|
||||
source="Appointment",
|
||||
type=type,
|
||||
defaultlogentrytime=datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
|
||||
subject=subject)])
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_logger()
|
||||
logger = logging.getLogger()
|
||||
logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||
log_sender = LogSender()
|
||||
response = log_sender.send_log("test2")
|
||||
print(response)
|
||||
@@ -12,6 +12,9 @@ class ExcelHelper:
|
||||
|
||||
def write_phone(self, phone_number):
|
||||
new_df = pandas.Series([phone_number])
|
||||
f = open("phone_list.txt", "a")
|
||||
f.write("{},".format(phone_number))
|
||||
f.close()
|
||||
self._df = pandas.concat([self._df, new_df])
|
||||
self._df.to_excel("phone_list.xlsx")
|
||||
|
||||
@@ -37,3 +40,7 @@ class ExcelHelper:
|
||||
if __name__ == '__main__':
|
||||
helper = ExcelHelper()
|
||||
helper.write_phone("88649614591")
|
||||
helper.write_phone("88649614591")
|
||||
helper.write_phone("88649614591")
|
||||
helper.write_phone("8864961591")
|
||||
helper.write_phone("88649614591")
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
88649614591,88649614591,88649614591,8864961591,88649614591,
|
||||
Binary file not shown.
Reference in New Issue
Block a user