Can’t help you with the sessions, but this should help:
// Logging:
$modx->setLogTarget('ECHO');
// FILE
// HTML
// setLogTarget() returns the current setting so you can set it back after logging.
$modx->log(modX::LOG_LEVEL_INFO, 'Here's some Info');
// modX::LOG_LEVEL_FATAL
// modX::LOG_LEVEL_ERROR
// modX::LOG_LEVEL_WARN
// Check the current user's permission:
if ($modx->hasPermission('element_tree')) {
// user has the permission
}
-
☆ A M B ☆
- 2,475 Posts
Ok, that’s a start.
So... what settings should be used if we want to log stuff to the "main" (?) log that’s visible under Revo manager: Reports --> Manager ? Is that a file? Or is it stored in the database?
Is there a "God" user in Revo? I’m not sure how to test permissions for a user to view data output from a particular module... I mean... where can a guy like me get a list of what all the valid permissions are to use as input to the "hasPermission()" method?
-
☆ A M B ☆
- 2,475 Posts
How about seeing which user group(s) or role(s) a user belongs to via the API?
How can i set the log file name. I would like to create for-each day a separate log file?
$modx->setLogTarget(array(
'target' => 'FILE',
'options' => array(
'filename' => 'dg_.' . strftime('%Y-%m-%dT')
)
));
Somehow did not work?
Thanks allot.
-
☆ A M B ☆
- 2,475 Posts
You know what I love? When I can’t remember how to do something, so I google it, and I find MY OWN QUESTION (and the awesome answers from los Dudes). Thanks guys.
Recommendation: do not do a separate file for each day’s logs. The problem you want to avoid is this: if you have thousands of individual files in any directory, listing the directory will give the server an aneurism (try it sometime). If you need this type of granularity, please consider using folders for each Year/Month so that each folder never gets too crowded. However, I think you’re defeating the purpose of the logs... I’ve been hired more than once to re-assemble log files that were strewn across the file system. It’s better to have one gigantic file in my opinion.
Quote from: Everett at Aug 24, 2010, 11:45 PM
You know what I love? When I can’t remember how to do something, so I google it, and I find MY OWN QUESTION (and the awesome answers from los Dudes). Thanks guys.
Wait ’til you’re my age. When I do that, way too many times I end up reading a message of my own telling someone else how to do it.