Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
I'd like to see a log of what the client has done (for example if they deleted something). Is there a way to enable a log?
Do you mean client as in “a logged in user of the site” deleting records they have access to or “your client, who owns the site” deleting files on the server?

If it’s server/file related, that seems like something your web hosting company might have more knowledge on.

Otherwise, if you’re looking to log front-end user actions, you could use <cms:log />. This comes in handy to validate things are working the way they should in production, particularly helpful around db_persist and send_email events. Also comes in handy during development of course.

For instance:
Code: Select all

<cms:db_persist
  _masterpage = “notifications.php”
  _mode = “create”
  _auto_title = “1”
  content = notify_content
  email = notify_email
>

  <cms:if k_success>

    <cms:set successfully_recorded=“1” scope=“global” />
    <cms:log “New notification recorded (<cms:show k_last_insert_id />)” file=“logs/notifications.txt” />
 
  <cms:else_if k_error />

    <cms:log “Notification recording failure | <cms:each k_error><cms:show item /><cms:if k_last_item><cms:else />, </cms:if></cms:each>” file=“logs/notifications.txt” />

  </cms:if>

</cms:db_persist>


<cms:if successfully_recorded>

  // send notification email

<cms:else />

  // send email about recording failure to developer

</cms:if>


<cms:send_email> tags also have a debug and logfile parameter.

Just be sure to log to files away from public consumption. The default is log.txt, which gets placed in the document root. If sensitive info gets logged here, it’ll be public :shock: , so I always explicitly log files to the snippets folder, as Couch makes that off limits to the public. Or you could add a .htaccess file to the log directory with “deny from all” to prevent access (just like the snippets directory). Likely a good idea to ignore logs in .gitignore too, if you’re using git.
Yes, it was front-end i was thinking of. Yet another tag i must have missed :)
Thank you, again! Just what i needed!
3 posts Page 1 of 1