Logs from external php file

ctdlg Member
edited May 6 in General support

Hello,
I try to add some logs in an external php file.

Example, extraction.php contains :
$logHeader = "{" . time() . ":" . gmdate("D, d M Y H:i:s") . " GMT}";
debugLog("$logHeader\n🟢 clvs actuelle : $clvsLine");

This php file is in /scripts
zenphoto folder is in /mutimedia
S
This file is called in image.php using the include function after < body >
<?php include(SERVERPATH . '/scripts/extraction.php'); ?>

Maybe extraction.php should start with

<?php // force UTF-8 Ø if (!defined('WEBPATH')) { die(); } ?>

But image.php already uses this code !
admin logs page should display my variable !

Thanks in advance.

Comments

  • acrylian Administrator, Developer

    I have no idea what "extraction.php" is

    The proper usages is debuglog($yourmessage, $reset) and/or additional parameters. Time and such is already handled.
    https://docs.zenphoto.org/1.6.6/namespaces/default.html#function_debugLog

  • acrylian Administrator, Developer

    Maybe extraction.php should start with

    <?php // force UTF-8 Ø if (!defined('WEBPATH')) { die(); } ?>

    That code is to make sure the theme page is accessed in the right context. Include files should not need that. Besides it would not hurt to add it there as well in case someone really accesses that directly. But it will otherwise just fail with errors.

  • ctdlg Member

    Thank you acrylian, problem solved with your help.

    My theme image.php uses this line (example)
    include($_SERVER['DOCUMENT_ROOT']) . '/scripts/personal-logs.php';

    My personal-logs.php file contains

    <?php // force UTF-8 Ø if (!defined('WEBPATH')) { die(); } ?> <?php debugLog("✅ Les logs sont bien gérés par Zenphoto depuis /scripts/affiche-logs.php"); ?>

    Zephoto debug log displays my personal logs, I can carry on on a project !
    I use php and ajax to dynamicaly change some pictures without reloading special image pages.

    <?php // force UTF-8 Ø if (!defined('WEBPATH')) { die(); } ?>
    Was the trick.

  • acrylian Administrator, Developer

    include($_SERVER['DOCUMENT_ROOT']) . '/scripts/personal-logs.php';

    So this is outside your install respectively thte theme? Otherwise the our path constants like SERVERPATH should be fitting.

    If the file is within your theme's folder you should not need the path and just include 'scripts/personal-logs.php' should work (that's how some themes include header or footer files).

    I don't remember when I added it but in 1.6.6 you can also create your own custom log file with debuglog() if necessary. See the arguments on the doc link above.

  • ctdlg Member

    Yes,
    /scripts -> my scripts
    /multimedia -> zenphoto
    /multimedia/themes/ctdlg ->my zenphoto theme folder.

    I will upgrade from 1.6.5 to 1.6.6 very soon, and, of course, test your new custom log file option !!

Sign In or Register to comment.