Open junjun17 opened 6 years ago
I added a logger function in Connector Controller like https://github.com/Studio-42/elFinder/wiki/Logging and in config/elfinder I added:
'options' => array( 'bind' => array('mkdir mkfile rename duplicate upload rm paste' => 'logger')),
but it does not work, please advice
Hi!
Did you find any solution to this? If so, how do you did it?
Thanks!
Hi to both!
I face the same problem and I think I have the way to make it work.
'options' => array( 'bind' => array( 'mkdir mkfile rename duplicate upload rm paste' => 'App\Http\Controllers\RepositoryController::log' ), ),
and in RepositoryController you have to write a method like this -is a pseudocopy of original logger function- (it stores a new line in table repository_log with the model RepositoryLog):
`
/**
* Create log record
*
* @param string $cmd command name
* @param array $result command result
* @param array $args command arguments from client
* @param elFinder $elfinder elFinder instance
* @return void|true
**/
public static function log($cmd, $result, $args, $elfinder) {
if (!empty($result['error'])) {
$log = new RepositoryLog;
$log->user_id = Auth::user()->id;
$log->command = $cmd;
$log->result_raw = serialize($result);
$log->result_type = 'error';
$log->result_data = implode(' ', $result['error']);
$log->save();
}
if (!empty($result['warning'])) {
$log = new RepositoryLog;
$log->user_id = Auth::user()->id;
$log->command = $cmd;
$log->result_raw = serialize($result);
$log->result_type = 'warning';
$log->result_data = implode(' ', $result['warning']);
$log->save();
}
if (!empty($result['removed'])) {
foreach ($result['removed'] as $file) {
$log = new RepositoryLog;
$log->user_id = Auth::user()->id;
$log->command = $cmd;
$log->result_raw = serialize($result);
$log->result_type = 'removed';
$log->result_data = $file['realpath'];
$log->save();
}
}
if (!empty($result['added'])) {
foreach ($result['added'] as $file) {
$log = new RepositoryLog;
$log->user_id = Auth::user()->id;
$log->command = $cmd;
$log->result_raw = serialize($result);
$log->result_type = 'added';
$log->result_data = $elfinder->realpath($file['hash']);
$log->save();
}
}
if (!empty($result['changed'])) {
foreach ($result['changed'] as $file) {
$log = new RepositoryLog;
$log->user_id = Auth::user()->id;
$log->command = $cmd;
$log->result_raw = serialize($result);
$log->result_type = 'changed';
$log->result_data = $elfinder->realpath($file['hash']);
$log->save();
}
}
}
`
Hope this helps!!
how to create a logging file like https://github.com/Studio-42/elFinder/wiki/Logging, I'm still confused how to implement it to laravel
thanks before