Jump to content

How to output log from module in front end


Recommended Posts

I have the "simple contact form" module. And it creates a log in Setup->logs (simplecontactform-log) for every sent email from the form. I want to output the logs in the front end? I also displaying the every email in the front end so i also want the specific log be attached to it. Is that possible? Please help..

Link to comment
Share on other sites

Well its hard to understand that page for a beginner when there is no real examples.

This is the closest i got.

$scf = $modules->get('SimpleContactForm');

$wire = $log->getLogs($scf);

foreach($wire as $hejda){
  echo $hejda . "<br>";
}

And it outputs

Array

Array

Array

Array

Array

Array

Link to comment
Share on other sites

But how do i get specific log? Lets say you are on a page that outputting the form message (front end). I only want that specific message attached to the page. Same date for example.

$myLogs = $log->getLines("simplecontactform-log");
    foreach ($myLogs as $logs) {
    echo $logs . "<br><br><br>";
}

 

Link to comment
Share on other sites

I can give you a simple example how to use the options array. 

In this example you would get all log entries for your log file that have been stored today. 

$entries = $log->getEntries("simplecontactform-log", ["dateFrom" => "2022-06-14 00:00", "dateTo" => "2022-06-14 23:59:59"]);
foreach($entries as $entry){
	//get log entry text, you can also get date, user and url
	$text = $entry["text"];
}

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...