CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识 & 商标
  • 商业解决方案
  • 周边商品
  • 自驾游
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助 & 支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
      • Engine
      • Formatter
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

SyslogLog 类

用于日志记录的 Syslog 流。将日志写入系统记录器

命名空间: Cake\Log\Engine

属性摘要

  • $_config 受保护
    array<string, mixed>

    运行时配置

  • $_configInitialized 受保护
    bool

    配置属性是否已使用默认值配置

  • $_defaultConfig 受保护
    array<string, mixed>

    此类的默认配置

  • $_levelMap 受保护
    array<int>

    用于将字符串名称映射回其 LOG_* 常量

  • $_open 受保护
    bool

    记录器连接是否打开

  • $formatter 受保护
    Cake\Log\Formatter\AbstractFormatter

方法摘要

  • __construct() 公共

    __construct 方法

  • __destruct() 公共

    关闭记录器连接

  • _configDelete() 受保护

    删除单个配置键。

  • _configRead() 受保护

    读取配置键。

  • _configWrite() 受保护

    写入配置键。

  • _open() 受保护

    提取对 openlog() 的调用以对其进行单元测试。此函数将初始化与系统记录器的连接

  • _write() 受保护

    提取对 syslog() 的调用以对其进行单元测试。此函数将执行系统记录器中的实际写入

  • alert() 公共

    必须立即采取行动。

  • configShallow() 公共

    将提供的配置与现有配置合并。与 config() 不同,该方法对嵌套键执行递归合并,此方法执行简单合并。

  • critical() 公共

    严重情况。

  • debug() 公共

    详细的调试信息。

  • emergency() 公共

    系统无法使用。

  • error() 公共

    运行时错误,不需要立即采取行动,但通常应该记录和监控。

  • getConfig() 公共

    返回配置。

  • getConfigOrFail() 公共

    返回此特定键的配置。

  • info() 公共

    有趣的事件。

  • interpolate() 受保护

    用上下文值替换消息字符串中的占位符。

  • levels() 公共

    获取此记录器感兴趣的级别。

  • log() 公共

    将消息写入 syslog

  • notice() 公共

    正常但重要的事件。

  • scopes() 公共

    获取此记录器感兴趣的范围。

  • setConfig() 公共

    设置配置。

  • warning() 公共

    异常情况,不是错误。

方法详细说明

__construct() ¶ 公共

__construct(array<string, mixed> $config = [])

__construct 方法

参数
array<string, mixed> $config 可选

配置数组

__destruct() ¶ 公共

__destruct()

关闭记录器连接

_configDelete() ¶ 受保护

_configDelete(string $key): void

删除单个配置键。

参数
string $key

要删除的键。

返回值
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_configRead() ¶ 受保护

_configRead(string|null $key): mixed

读取配置键。

参数
string|null $key

要读取的键。

返回值
混合

_configWrite() ¶ 受保护

_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void

写入配置键。

参数
array<string, mixed>|string $key

要写入的键。

mixed $value

要写入的值。

string|bool $merge 可选

True 表示递归合并,'shallow' 表示简单合并,false 表示覆盖,默认为 false。

返回值
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_open() ¶ 受保护

_open(string $ident, int $options, int $facility): void

提取对 openlog() 的调用以对其进行单元测试。此函数将初始化与系统记录器的连接

参数
string $ident

要添加到所有记录消息的的前缀

int $options

用于记录消息的选项标志

int $facility

要记录到的流或工具

返回值
void

_write() ¶ 受保护

_write(int $priority, string $message): bool

提取对 syslog() 的调用以对其进行单元测试。此函数将执行系统记录器中的实际写入

参数
int $priority

消息优先级。

string $message

要记录的消息。

返回值
bool

alert() ¶ 公共

alert(stringStringable $message, mixed[] $context = []): void

必须立即采取行动。

示例:整个网站停机,数据库不可用等。这应该触发短信警报并把你叫醒。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

configShallow() ¶ 公共

configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this

将提供的配置与现有配置合并。与 config() 不同,该方法对嵌套键执行递归合并,此方法执行简单合并。

设置特定值

$this->configShallow('key', $value);

设置嵌套值

$this->configShallow('some.nested.key', $value);

同时更新多个配置设置

$this->configShallow(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整配置数组。

mixed|null $value 可选

要设置的值。

返回值
$this

critical() ¶ 公共

critical(stringStringable $message, mixed[] $context = []): void

严重情况。

示例:应用程序组件不可用,意外异常。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

debug() ¶ 公共

debug(stringStringable $message, mixed[] $context = []): void

详细的调试信息。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

emergency() ¶ 公共

emergency(stringStringable $message, mixed[] $context = []): void

系统无法使用。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

error() ¶ 公共

error(stringStringable $message, mixed[] $context = []): void

运行时错误,不需要立即采取行动,但通常应该记录和监控。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

getConfig() ¶ public

getConfig(string|null $key = null, mixed $default = null): mixed

返回配置。

用法

读取整个配置

$this->getConfig();

读取特定值

$this->getConfig('key');

读取嵌套值

$this->getConfig('some.nested.key');

读取默认值

$this->getConfig('some-key', 'default-value');
参数
string|null $key 可选

要获取的键,如果要获取整个配置则为 null。

mixed $default 可选

键不存在时的返回值。

返回值
混合

getConfigOrFail() ¶ public

getConfigOrFail(string $key): mixed

返回此特定键的配置。

此键的配置值必须存在,不能为 null。

参数
string $key

要获取的键。

返回值
混合
抛出
InvalidArgumentException

info() ¶ public

info(stringStringable $message, mixed[] $context = []): void

有趣的事件。

示例:用户登录,SQL 日志。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

interpolate() ¶ protected

interpolate(Stringable|string $message, array $context = []): string

用上下文值替换消息字符串中的占位符。

参数
Stringable|string $message

格式化的消息。

array $context 可选

占位符值的上下文。

返回值
string

levels() ¶ public

levels(): list<string>

获取此记录器感兴趣的级别。

返回值
list<string>

log() ¶ public

log(mixed $level, Stringable|string $message, mixed[] $context = []): void

将消息写入 syslog

将 $level 映射回 LOG_ 常量值,将多行消息拆分为多个日志消息,将所有消息通过配置中定义的格式传递。

参数
mixed $level

您正在执行的日志的严重程度级别。

Stringable|string $message

您要记录的消息。

mixed[] $context 可选

有关记录消息的更多信息

返回值
void
另请参见
\Cake\Log\Log::$_levels

notice() ¶ public

notice(stringStringable $message, mixed[] $context = []): void

正常但重要的事件。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

scopes() ¶ public

scopes(): list<string>|null

获取此记录器感兴趣的范围。

返回值
list<string>|null

setConfig() ¶ public

setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this

设置配置。

用法

设置特定值

$this->setConfig('key', $value);

设置嵌套值

$this->setConfig('some.nested.key', $value);

同时更新多个配置设置

$this->setConfig(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整配置数组。

mixed|null $value 可选

要设置的值。

bool $merge 可选

是否递归合并或覆盖现有配置,默认为 true。

返回值
$this
抛出
Cake\Core\Exception\CakeException
尝试设置无效键时。

warning() ¶ public

warning(stringStringable $message, mixed[] $context = []): void

异常情况,不是错误。

示例:使用已弃用的 API,API 使用不当,不希望发生但并非错误的事情。

参数
stringStringable $message
mixed[] $context 可选
返回值
void

属性详情

$_config ¶ protected

运行时配置

类型
array<string, mixed>

$_configInitialized ¶ protected

配置属性是否已使用默认值配置

类型
bool

$_defaultConfig ¶ protected

此类的默认配置

默认情况下,消息格式为:级别:消息

要覆盖日志格式(例如,添加您自己的信息),请在配置此记录器时定义 format 键

如果您希望在所有消息之前包含一个前缀,例如标识应用程序或 Web 服务器,请使用 prefix 选项。请记住,前缀由使用 syslog 的所有流共享,因为它取决于正在运行的进程。对于仅由一个流使用的本地前缀,您可以使用 format 键。

示例

 Log::config('error', ]
     'engine' => 'Syslog',
     'levels' => ['emergency', 'alert', 'critical', 'error'],
     'prefix' => 'Web Server 01'
 ]);
类型
array<string, mixed>

$_levelMap ¶ protected

用于将字符串名称映射回其 LOG_* 常量

类型
array<int>

$_open ¶ protected

记录器连接是否打开

类型
bool

$formatter ¶ protected

类型
Cake\Log\Formatter\AbstractFormatter
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识 & 商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助 & 支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成