Juergen Posted March 29, 2018 Share Posted March 29, 2018 Hello @ all, I am logging all submissions via my contact form in the log files with the following line of code: $log->save('contact-form', 'Email: '.$emailvalue.'<br />Betreff: '.$subjectvalue.'<br /> Nachricht: '.$commentsvalue); So the logfile is called "contact-form". Unfortnunately all br-tags will be displayed as letters and not as line-breaks. Maybe someone can give me a hint how to use line-breaks in log files. Thanks Link to comment Share on other sites More sharing options...
DaveP Posted March 29, 2018 Share Posted March 29, 2018 Would \n or \r\n work instead of <br>? 1 Link to comment Share on other sites More sharing options...
kongondo Posted March 29, 2018 Share Posted March 29, 2018 22 minutes ago, DaveP said: Would \n or \r\n work instead of <br>? No . Tested... 1 1 Link to comment Share on other sites More sharing options...
Juergen Posted March 29, 2018 Author Share Posted March 29, 2018 Thanks for testing @kongondo, but I have tried this before with no luck. Another opportunity would be to add separate colums (<td>) for each entry, but I also dont know how. Serializing the entries dont work. Link to comment Share on other sites More sharing options...
alxndre Posted March 29, 2018 Share Posted March 29, 2018 I don't think this is possible because WireLog replaces the escape characters with spaces: // somewhere in WireLog::save() $text = str_replace(array("\r", "\n", "\t"), ' ', $text); and it also sanitizes the tags when outputting. 2 1 Link to comment Share on other sites More sharing options...
bernhard Posted March 29, 2018 Share Posted March 29, 2018 I always use pages to log mails... just use a ckeditor field and you can see your html content. Or why exactly do you want to use logfiles? 1 Link to comment Share on other sites More sharing options...
Juergen Posted March 29, 2018 Author Share Posted March 29, 2018 Its a fast and simply way to store sent mails. Its only there for the purpose if someone says he has sent a mail, but the site owner doesnt receive it. The log file will be written after PHP mailers send function was successfully triggered. Link to comment Share on other sites More sharing options...
Robin S Posted March 29, 2018 Share Posted March 29, 2018 You won't be able to use $log->save() for the reason @alxndre mentioned, and you won't be able to use the admin log viewer because a) it uses new lines to identify each log entry so therefore one entry cannot contain more than one line, and b) it entity encodes HTML for security reasons. But you can use PHP functions like error_log() or file_put_contents() to create your own log file (create the "custom-logs" folder first). $text = date("Y-m-d H:i:s") . "\nHello, how \nare you?\n\n"; // your text, include newlines if needed error_log($text, 3, $config->paths->assets . "custom-logs/mail.txt") 6 Link to comment Share on other sites More sharing options...
BitPoet Posted March 29, 2018 Share Posted March 29, 2018 3 minutes ago, Robin S said: But you can use PHP functions like error_log() or file_put_contents() to create your own log file (create the "custom-logs" folder first). Or you can steal one or two methods @ryan's code, stuff them into your little module, tweak a few lines and add even more fun to PW Attached is a quick & dirty little module (actually, two of them) that adds: $log->mailLog($your, $fields, $ending, $with, ..., $messagebody) [pass as many arguments as you like; the last one will always have white-space set to wrap] a special log viewer at Setup -> Mail Log that displays as many columns as you sent to mailLog() It uses some unlikely to naturally occur text patterns for newlines and field separators and fools ProcessLogger::executeView into thinking it is pointed to the mail log, and that way lets it do the heavy lifting. ProcessMailLogger.zip 10 Link to comment Share on other sites More sharing options...
bernhard Posted March 29, 2018 Share Posted March 29, 2018 This community is crazy 3 Link to comment Share on other sites More sharing options...
gebeer Posted March 30, 2018 Share Posted March 30, 2018 I had this problem once and solved it with JSON. It is quick and simple. In your case $logmsg = array( 'Email' => $emailvalue, 'Betreff' => $subjectvalue, 'Nachricht' => $commentsvalue ); $log->save('contact-form', json_encode($logmsg)); 4 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now