Mohse Taheri
Mohse Taheri

Reputation: 741

How to use cakephp classes like cakelog in external script

I have a php script in webroot folder and i want to use CakeLog::write inside it.

Is there anyway to include cakephp classes in this kind of scripts?

I know that i can bring my script to some controller action but I want to know is there anyway to use cakephp classes outside of it?

Upvotes: 0

Views: 138

Answers (1)

Mohse Taheri
Mohse Taheri

Reputation: 741

after a month it seems that there is no answer for this question. for solving my problem I wrote my own CakeLog class with write method:

my CakeLog config in bootstrap.php:

CakeLog::config("default", array(
    'engine' => 'Syslog',
    'prefix' => 'tgui',
    'flag' => LOG_ODELAY | LOG_PID,
    'facility' => LOG_LOCAL0
));

so my custom class will be following:

class CakeLog {
    public static function write($type, $msg) {
        openlog("tgui", LOG_ODELAY | LOG_PID, LOG_LOCAL0);
        syslog($type, $msg);
        closelog();
   }
}

Upvotes: 1

Related Questions