autoaction / logging
Auto Action 云日志
1.2.3
2022-10-20 13:42 UTC
Requires
- php: >=7.0
Requires (Dev)
- mockery/mockery: ^1.5
- phpunit/phpunit: ^5.3
Suggests
- google/cloud-logging: Required to use this package with Cloud Logger
README
<?php
use AutoAction\Logging\Client\LoggerAAV;
use AutoAction\Logging\Config\Generic;
require_once 'vendor/autoload.php';
// Configuração
$config = new Generic('project-id-here');
$config->setBatchEnabled(true);
$config->setEnvironment(ENVIRONMENT);
$config->addExtraLabel('mvc_module',$this->dispatcher->getModuleName());
$config->addExtraLabel('mvc_controller',$this->dispatcher->getControllerName());
$config->addExtraLabel('mvc_action',$this->dispatcher->getActionName());
$config->addExtraLabel('instance_id',\SessionData::$instance_id);
$config->addExtraLabel('entity_id',\SessionData::$entity_id);
$config->addExtraLabel('user_id',\SessionData::$user_id);
$config->addExtraLabel('country_id',\SessionData::$country_id);
$config->setRouteName('route-full-name');
$config->setServiceName('my-system-name');
LoggerAAV::init($config);
LoggerAAV::addGenericContext('valuation_id', 12354);
使用详情
由于日志包已安装在系统中,您只需调用 LoggerAAV::info|error|warning|alert|emergency|notice('日志描述',['context'=>'这里']);
同样,定义全局上下文也很重要,例如在初始化控制器之前,定义 LoggerAAV::setScope(ScopeEnum::VALUATION);
还可以注册异常 LoggerAAV::exception($e);