apps scripts edit log

I have the Google Sheets application, I added a new tab “Edit Log” to display the logs. The logs are displayed when I edit the form in Google Sheets. How can I make them show logs when I edit directly an application —> main.JS.html that changes sheet parameters?

function onEdit(e) {
var timestamp = new Date();

var user = e.user;

var cell = e.range.getA1Notation();

var oldValue = e.oldValue;

var newValue = e.value;

var sheetName = e.source.getActiveSheet().getName();

var logSheet = e.source.getSheetByName("Edit Log");

if (logSheet == null) {

logSheet = e.source.insertSheet("Edit Log");

logSheet.appendRow(["Timestamp", "User", "Cell", "Old Value", "New Value", "Sheet Name"]);

}

logSheet.appendRow([timestamp, user, cell, oldValue, newValue, sheetName]);

}

code edits to make editing work