Implementing application logging and need assistance. My idea is to use an <cms:embed> with variables to writeout snippet to handle writing to a log file. This way I can set the log filenames depending on the part of the application with the same <cms:embed> throughout the application.
Each part of the application has a different configuration file embed and inside their are two <cms:set> variables for whether the logging should occur and the filename to use.
Inside the application there is <cms:php> block, my question is how can I get the php variable $total into the embed msg field within this <cms:php>, is this possible?
Here is a very basic version for example purposes:
Here is the writeout.html file:
This currently works but the total does not pass into the log file, resulting in:
Also open to ways to improve this logging performance wise if any, ty.
Each part of the application has a different configuration file embed and inside their are two <cms:set> variables for whether the logging should occur and the filename to use.
- Code: Select all
<cms:set log_status='1' scope='global' /> <cms:set log_file='.charges.log' scope='global' />
Inside the application there is <cms:php> block, my question is how can I get the php variable $total into the embed msg field within this <cms:php>, is this possible?
Here is a very basic version for example purposes:
- Code: Select all
<cms:embed 'configuration.html' /> <cms:php> $total = "100.00"; <cms:embed 'writeout.html' msg="- total {$total}" run=log_status file=log_file /> </cms:php>
Here is the writeout.html file:
- Code: Select all
<cms:set go_log = "<cms:get 'run' local_only='1' />" scope='local' /> <cms:if go_log="1"> <cms:php> file_put_contents("<cms:get 'file' local_only='1' />", "<cms:get 'msg' local_only='1' />".PHP_EOL , FILE_APPEND | LOCK_EX); </cms:php> </cms:if>
This currently works but the total does not pass into the log file, resulting in:
- Code: Select all
- total
Also open to ways to improve this logging performance wise if any, ty.