本文整理汇总了PHP中Log::logger方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::logger方法的具体用法?PHP Log::logger怎么用?PHP Log::logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public static function initialize($logger)
{
if (!is_null(self::$logger)) {
throw new \RuntimeException(__METHOD__ . ' can be called only once per script execution');
}
self::$logger = $logger;
}
示例2: log
/**
* Logs data to the shibboleth debug log
*
* @param string $msg the message to log
* @param string|object $data additional data to log
* @return void
**/
private static function log($msg, $data = '')
{
static $params;
if (!isset($params)) {
$params = Plugin::params('authentication', 'shibboleth');
}
if ($params->get('debug_enabled', true)) {
if (!\Log::has('shib')) {
$location = $params->get('debug_location', '/var/log/apache2/php/shibboleth.log');
$location = explode(DS, $location);
$file = array_pop($location);
\Log::register('shib', ['path' => implode(DS, $location), 'file' => $file, 'level' => 'info', 'format' => "%datetime% %message%\n"]);
}
// Create a token to identify related log entries
if (!($cookie = Cookie::eat('shib-dbg-token'))) {
$token = base64_encode(uniqid());
Cookie::bake('shib-dbg-token', time() + 60 * 60 * 24, ['shib-dbg-token' => $token]);
} else {
$token = $cookie->{'shib-dbg-token'};
}
$toBeLogged = "{$token} - {$msg}";
if (!empty($data)) {
$toBeLogged .= ":\t" . (is_string($data) ? $data : json_encode($data));
}
\Log::logger('shib')->info("{$toBeLogged}");
}
}
示例3: run
/**
* Run the credential importer
*
* @param string $json_file The JSON file that contains a list of the APIs and their credentials
*/
public static function run($json_file = null)
{
if (empty($json_file) || file_exists($json_file) === false) {
exit('You must specify a valid JSON file that contains your credentials.' . PHP_EOL);
}
if (($json = json_decode(file_get_contents($json_file), true)) === null) {
exit('The JSON file does not contain valid JSON text.' . PHP_EOL);
}
// Find the API version to use for importing the keys
$version = 'V1';
if (!empty($json[0]['version'])) {
if (is_int($json[0]['version']) && \Module::exists('V' . $json[0]['version'])) {
\Module::load('V' . $json[0]['version']);
$version = 'V' . $json[0]['version'];
} else {
\Module::load($version);
}
array_shift($json);
} else {
\Module::load($version);
}
$error = false;
foreach ($json as $entry) {
// We need these keys for each entry.
if (!array_key_exists('api', $entry) || !array_key_exists('credentials', $entry)) {
echo \Cli::color('The JSON data is in the wrong format. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
if (!is_string($entry['api'])) {
echo \Cli::color('The API name must be a string. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
// Make sure that we have credentials to add to the DB.
if (empty($entry['credentials']) || !is_array($entry['credentials'])) {
echo \Cli::color('The array of credentials for ' . $entry['api'] . ' is empty. Skipping.' . PHP_EOL, 'yellow');
$error = true;
continue;
}
$response = call_user_func('\\' . $version . '\\Keyring::set_credentials', $entry['credentials'], $entry['api']);
// Show and log the result
if ($response === true) {
$success_text = 'Successfully imported the credentials for API: ' . $entry['api'];
echo \Cli::color($success_text . PHP_EOL, 'green');
\Log::logger('INFO', 'CLI:ADD_CREDENTIALS', $success_text, __METHOD__, array('api' => $entry['api']));
} else {
$error_text = 'Failed to import the credentials for API: ' . $entry['api'];
echo \Cli::color('Warning: ' . $error_text . PHP_EOL, 'red');
$error = true;
\Log::logger('ERROR', 'CLI:ADD_CREDENTIALS', $error_text, __METHOD__, array('api' => $entry['api']));
}
}
// Display the summary.
if ($error === true) {
echo \Cli::color(PHP_EOL . 'Some credentials were not added to the database. See the error log for more details.' . PHP_EOL, 'red');
} else {
echo \Cli::color(PHP_EOL . 'All credentials were successfully added to the database.' . PHP_EOL, 'green');
}
}
示例4: run
/**
* Выполняет обработку запроса
*
* @param WS_Environment $env
*
* @return mixed
*/
public function run(WS_Environment $env)
{
$handler = Log_FirePHP::Handler();
$handler->where('level', '>=', $this->log_level);
Log::logger()->handler($handler);
$response = $this->application->run($env);
$handler->dump($response);
return $response;
}
示例5: log
/**
* Logs a message and adds <br /> html tag.
* @param string $level Log level
* @param string $message Log message
*/
public static function log($level, $message)
{
// check if to create new logger instance
if (Log::$logger == null) {
Logger::configure(realpath(dirname(__FILE__)) . '/log.xml');
Log::$logger = Logger::getLogger('main');
}
// call log function in logger instance
call_user_func(array(Log::$logger, $level), $message);
}
示例6: salvarLog
public static function salvarLog($modulo, $acao, $mensagem)
{
$log = new Log();
$log->modulo = $modulo;
$log->acao = $acao;
$log->mensagem = $mensagem;
if (!empty($_SESSION['auth']['id'])) {
$log->fkUsuario = $_SESSION['auth']['id'];
}
$log->logger($log);
}
示例7: forge
/**
* Logging wrapper for off site requests (Allows for desired log formatting)
*
* @param string $uri The URL to execute
* @param string $options The type of request
* @param string $method The HTTP method to use for the request
*/
public static function forge($uri = NULL, $options = true, $method = NULL)
{
/*
* If someone uses this for internal calls, we'll still allow it to function, but we don't log it since it
* isn't a remote request.
*/
if (is_string($options)) {
// We only grab the URL and method, not params or headers since the latter two could contain sensitive data.
$tokens = array('url' => $uri, 'method' => $method);
// Log the request
\Log::logger('INFO', 'REMOTE:' . $options, 'Started execution of an off-site request', __METHOD__, $tokens);
}
return parent::forge($uri, $options, $method);
}
示例8: run
/**
* Validate the request to make sure we have trusted and sufficient data.
*
* @return mixed True on success, or an array of error data on fail
*/
public static function run()
{
/**
* Verify that we have at least an "api" or "data-call" token.
*/
if (\V1\APIRequest::get('api', false) === false && \V1\APIRequest::get('data-call', false) === false) {
return \Utility::format_error(400, \V1\Err::BAD_BODY, \Lang::get('v1::errors.bad_body'));
}
/**
* Easter egg processing plant
*/
if (\V1\APIRequest::get('api') === 'I\'m a teapot') {
return \Utility::format_error(418, \V1\Err::IM_A_TEAPOT, str_replace("\t", '', \Lang::get('v1::errors.im_a_teapot')));
}
/**
* AUTHORIZATION
*/
// Once we've authenticated to start running calls from one Data Call, we don't authenticate again.
if (\Session::get('data_call', false) === false) {
// If they failed to authenticate, then issue a 401 unauthorized error.
if (\V1\Account::authenticate() === false) {
// Log the failure.
\Log::logger('INFO', 'AUTHORIZE:FAIL', \Lang::get('log.authorize_fail'), __METHOD__, array('consumer_key' => \Session::get('consumer_key', 'NOT SET'), 'public_mode' => \Session::get('public', 'NOT SET')));
return \Utility::format_error(401);
}
// Log the success.
\Log::logger('INFO', 'AUTHORIZE:SUCCESS', \Lang::get('log.authorize_success'), __METHOD__, array('consumer_key' => \Session::get('consumer_key', 'NOT SET'), 'public_mode' => \Session::get('public', 'NOT SET')));
/**
* DOWNGRADE PROCESSING
*/
\V1\Account::downgrade();
}
/**
* GLOBAL LIMITS
*/
if (static::check_global_limits() === false) {
return \Utility::format_error(429, \V1\Err::MAXED_OUT_LIMITS, \Lang::get('v1::errors.maxed_out_limits'));
}
return true;
}
示例9: _processTask
protected function _processTask()
{
try {
if ($this->isAtom) {
foreach ($this->tasks as $task) {
if (is_array($task)) {
$task = AbstractTask::createTask($task);
}
$task->run();
}
} else {
foreach ($this->tasks as $task) {
if (is_array($task)) {
$task = AbstractTask::createTask($task);
}
$task->push();
}
}
} catch (Exception $e) {
Log::logger()->addError($e->getMessage);
}
}
示例10: _writeTo
protected static function _writeTo($stringData)
{
if (!file_exists(INIT::$LOG_REPOSITORY) || !is_dir(INIT::$LOG_REPOSITORY)) {
mkdir(INIT::$LOG_REPOSITORY);
}
if (!empty(self::$fileName)) {
self::$fileNamePath = LOG_REPOSITORY . "/" . self::$fileName;
} else {
self::$fileNamePath = LOG_REPOSITORY . "/" . LOG_FILENAME;
}
if (self::$useMonolog) {
try {
if (empty(self::$logger)) {
$matecatRedisHandler = new \RedisHandler();
// Init a RedisHandler with a LogstashFormatter.
// The parameters may differ depending on your configuration of Redis.
// Important: The parameter 'logs' must be equal to the key you defined
// in your logstash configuration.
$redisHandler = new RedisHandler($matecatRedisHandler->getConnection(), 'phplogs');
$logStashFormatter = new LogstashFormatter('MateCat', gethostname());
$redisHandler->setFormatter($logStashFormatter);
//Log on file
$fileHandler = new StreamHandler(self::$fileNamePath);
$fileFormatter = new LineFormatter(null, null, true, true);
$fileHandler->setFormatter($fileFormatter);
// Create a Logger instance with the RedisHandler
self::$logger = new Logger('MateCat', array($redisHandler, $fileHandler));
}
self::$logger->debug($stringData);
} catch (Exception $e) {
file_put_contents(self::$fileNamePath, $stringData, FILE_APPEND);
}
} else {
file_put_contents(self::$fileNamePath, $stringData, FILE_APPEND);
}
}
示例11: set_logger
public static function set_logger($value)
{
self::$logger = $value;
}
示例12: finalize
/**
* Завершает выполнение
*
* @param int $status
*/
protected function finalize($status)
{
$this->shutdown();
Log::logger()->close();
return $this->exit_wrapper($status);
}
示例13: resetLogger
/**
* Ugly workaround to reset the logger, so the method _writeTo re-initialize the logger configuration
*
*/
public static function resetLogger()
{
self::$logger = null;
}
示例14: load_childs_by
protected function load_childs_by($rows, $input)
{
$child_count = 0;
$result_child = $child = $this->extract_parent_ids(array_keys($input));
$i = 0;
while (count($child) > 0) {
$child = $this->extract_parent_ids(array_keys($child));
$result_child += $child;
$i++;
}
Log::logger()->debug('depth', $i);
$rows += $result_child;
return array($rows, $result_child);
}
示例15: test_logger
public function test_logger()
{
$tokens = array('test token 1' => 'value', 'testtoken2' => 'value', '`~!@#$%^&*()_+-=[]{}\\|;:\'",<.>/?' => 'value');
\Log::logger('INFO', 'PHPUNIT:LOGGER', 'The PHPUnit test for \\Log::logger() was successful.', __METHOD__, $tokens);
// If we don't get errors, then we're good to go.
}