本文整理汇总了PHP中Log::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::instance方法的具体用法?PHP Log::instance怎么用?PHP Log::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: self
public static function &get_instance()
{
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例2: getInstance
public static function getInstance()
{
if (self::$instance == NULL) {
self::$instance = new self();
}
return self::$instance;
}
示例3: logger
function logger($level, $msg, $method = null)
{
static $labels = array(100 => 'DEBUG', 200 => 'INFO', 250 => 'NOTICE', 300 => 'WARNING', 400 => 'ERROR', 500 => 'CRITICAL', 550 => 'ALERT', 600 => 'EMERGENCY', 700 => 'ALL');
// make sure $level has the correct value
if (is_int($level) and !isset($labels[$level]) or is_string($level) and !array_search(strtoupper($level), $labels)) {
throw new \FuelException('Invalid level "' . $level . '" passed to logger()');
}
if (is_string($level)) {
$level = array_search(strtoupper($level), $labels);
}
// get the levels defined to be logged
$loglabels = \Config::get('log_threshold');
// bail out if we don't need logging at all
if ($loglabels == \Fuel::L_NONE) {
return false;
}
// if profiling is active log the message to the profile
if (\Config::get('profiling')) {
\Console::log($method . ' - ' . $msg);
}
// if it's not an array, assume it's an "up to" level
if (!is_array($loglabels)) {
$a = array();
foreach ($labels as $l => $label) {
$l >= $loglabels and $a[] = $l;
}
$loglabels = $a;
}
// do we need to log the message with this level?
if (!in_array($level, $loglabels)) {
return false;
}
return \Log::instance()->log($level, (empty($method) ? '' : $method . ' - ') . $msg);
}
示例4: getInstance
public static function getInstance()
{
if (null == self::$instance) {
self::$instance = new Log();
}
return self::$instance;
}
示例5: action_index
public function action_index()
{
$request = $this->request->current();
if ($request->post('submit')) {
$login = $request->post('login');
$password = $request->post('password');
$ip = Request::$client_ip;
$user_agent = Request::$user_agent;
$remember = (bool) $this->request->post('remember');
$fail_login_checker = new Auth_Admin_Checker($login, $ip);
if ($fail_login_checker->check()) {
$admin = ORM::factory('admin')->where('username', '=', $login)->and_where('delete_bit', '=', 0)->and_where('active', '=', 1)->find();
try {
if ($this->acl->auth()->login($admin, $password, $remember)) {
$url = Session::instance()->get('BACK_URL');
$request->redirect(empty($url) ? Route::url('admin') : $url);
} else {
// Store fail login attempt
$fail_login_checker->add($password, $user_agent);
$this->template->set('error', __('Authentication error'));
}
} catch (ORM_Validation_Exception $e) {
Log::instance()->add(Log::ERROR, $e->errors('') . '[' . __FILE__ . '::' . __LINE__ . ']');
}
} else {
$this->template->set('error', __('To many failed login attempts. Please, wait :minutes minutes and try again.', array(':minutes' => ceil($fail_login_checker->fail_interval() / 60))));
}
}
$this->template->set('logo', $this->config['logo']);
}
示例6: load_parts
/**
* Load adittionnal content part
*
* @param string $parts part name or list of part names
* @param string $sub_directory subdirectory name
*
* @return array
**/
public function load_parts($parts, $subcategory = NULL)
{
$parts = func_get_arg(0);
$sub_directory = func_get_arg(1);
$sub_directory = $sub_directory ? $sub_directory . '/' : NULL;
$result = array();
if (strpos($parts, ',') === FALSE) {
// Just one entry
try {
$result[] = new Model_Page($sub_directory . $parts);
} catch (Kohana_exception $e) {
Log::instance()->add(Log::WARNING, $e->getMessage());
}
} else {
// Multiples entries
foreach (explode(',', $parts) as $part) {
try {
$result[] = new Model_Page($sub_directory . $part);
} catch (Kohana_exception $e) {
Log::instance()->add(Log::WARNING, $e->getMessage());
}
}
}
return $result;
}
示例7: __construct
public function __construct()
{
$this->input = new Input();
$this->config = Config::instance();
$this->log = Log::instance();
$this->log->write('debug', 'Library Class Initialized');
}
示例8: newInstance
public static function newInstance()
{
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
示例9: get_instance
public static function get_instance($log_level = '', $filename = '')
{
if (empty(self::$instance)) {
self::$instance = new Log($log_level, $filename);
}
return self::$instance;
}
示例10: background
/**
* Runs the function in backgroung
* Called from our application, kohana is always loaded
*
* @param string $call_back function name to be called in background
* @param array $params parameters that the call_back can recieve in order!
* @param integer $priority for the system to do such task
* @return integer PID
*/
public static function background($call_back, $params = NULL, $priority = NULL)
{
if (self::is_callable($call_back)) {
//if (Kohana::$environment == Kohana::DEVELOPMENT)
//return self::execute($call_back, base64_encode(serialize($params)) );
$script = 'cli';
//preparing the command to execute
if (is_array($params)) {
$command = 'php -f ' . APPPATH . $script . EXT . ' ' . $_SERVER['KOHANA_ENV'] . ' ' . $call_back . ' ' . base64_encode(serialize($params)) . '';
} else {
//no params the -1 is because ::execute requires a value before the jobid if not in the cli won't work
$command = 'php -f ' . APPPATH . $script . EXT . ' ' . $_SERVER['KOHANA_ENV'] . ' ' . $call_back . ' -1';
}
//priority check
if ($priority !== NULL) {
$command = 'nohup nice -n ' . $priority . ' ' . $command;
} else {
$command = 'nohup ' . $command;
}
//adding output
//$command = 'su - www-data -c "'.$command.' >/dev/null 2>/dev/null"';
$command .= ' > /dev/null & echo $!';
//execute
//Log::instance()->add(LOG_DEBUG,'Exec->background - command: '.$command);
//d($command);
$pid = shell_exec($command);
//$pid = shell_exec($command.' >/dev/null &'); //another way without priority
//returning
//Log::instance()->add(LOG_DEBUG,'Exec->background - Return value PID:'.$pid);
return (int) $pid;
} else {
Log::instance()->add(LOG_ERR, 'Exec->background - call_back not found - ' . print_r($call_back, 1));
return FALSE;
}
}
示例11: getInstance
/**
* @return Log
*/
static function getInstance()
{
if (empty(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
示例12: inst
public function inst()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例13: _converting
private function _converting()
{
if (!empty($this->conv_func)) {
foreach ($this->conv_func as $f) {
$call_p = [];
if (is_string($f)) {
$call_f = [$this, $f];
} elseif (is_array($f) and is_string($f[0]) and is_array($f[1])) {
$call_f = [$this, $f[0]];
$call_p = $f[1];
} else {
Log::instance()->error("Incorrect format function parameters.");
return FALSE;
}
if (!is_callable($call_f, TRUE)) {
Log::instance()->error("Function: {$f} may not be called.");
return FALSE;
}
$ret = call_user_func_array($call_f, $call_p);
if ($ret === FALSE) {
Log::instance()->error("Function: {$call_f[1]} returned FALSE.");
return FALSE;
} elseif ($this->break_conv === TRUE) {
break;
}
}
}
return TRUE;
}
示例14: getInstance
public static function getInstance()
{
if (!self::$instance instanceof self) {
$startTime = defined('PROCESS_START_TIME') ? PROCESS_START_TIME : microtime(true) * 1000;
self::$instance = new self($GLOBALS['LOG'], $startTime);
}
return self::$instance;
}
示例15: singleton
public static function singleton($_idUser = null)
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c($_idUser);
}
return self::$instance;
}