本文整理汇总了PHP中pocketmine\utils\MainLogger::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP MainLogger::warning方法的具体用法?PHP MainLogger::warning怎么用?PHP MainLogger::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\MainLogger
的用法示例。
在下文中一共展示了MainLogger::warning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MainLogger
\date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
if (!\ini_get("date.timezone")) {
if ($timezone = detect_system_timezone() and \date_default_timezone_set($timezone)) {
//Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
\ini_set("date.timezone", $timezone);
} else {
//If system timezone detection fails or timezone is an invalid value.
if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = \json_decode($response, \true) and $ip_geolocation_data['status'] != 'fail' and \date_default_timezone_set($ip_geolocation_data['timezone'])) {
//Again, for redundancy.
\ini_set("date.timezone", $ip_geolocation_data['timezone']);
} else {
\ini_set("date.timezone", "UTC");
\date_default_timezone_set("UTC");
$logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
}
}
} else {
/*
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
* an incorrect timezone abbreviation in php.ini apparently.
*/
$default_timezone = \date_default_timezone_get();
if (\strpos($default_timezone, "/") === \false) {
$default_timezone = \timezone_name_from_abbr($default_timezone);
\ini_set("date.timezone", $default_timezone);
\date_default_timezone_set($default_timezone);
}
}
function detect_system_timezone()
示例2: MainLogger
date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
if (!ini_get("date.timezone")) {
if ($timezone = detect_system_timezone() and date_default_timezone_set($timezone)) {
//Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
ini_set("date.timezone", $timezone);
} else {
//If system timezone detection fails or timezone is an invalid value.
if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = json_decode($response, true) and $ip_geolocation_data['status'] != 'fail' and date_default_timezone_set($ip_geolocation_data['timezone'])) {
//Again, for redundancy.
ini_set("date.timezone", $ip_geolocation_data['timezone']);
} else {
ini_set("date.timezone", "UTC");
date_default_timezone_set("UTC");
$logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
}
}
} else {
/*
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
* an incorrect timezone abbreviation in php.ini apparently.
*/
$timezone = ini_get("date.timezone");
if (strpos($timezone, "/") === false) {
$default_timezone = timezone_name_from_abbr($timezone);
ini_set("date.timezone", $default_timezone);
date_default_timezone_set($default_timezone);
} else {
date_default_timezone_set($timezone);
}
示例3: MainLogger
date_default_timezone_set("UTC");
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
if (!ini_get("date.timezone")) {
if ($timezone = detect_system_timezone() and date_default_timezone_set($timezone)) {
//Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some program wants to read timezone data from the ini.
ini_set("date.timezone", $timezone);
} else {
//If system timezone detection fails or timezone is an invalid value.
if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = json_decode($response, true) and $ip_geolocation_data['status'] !== 'fail' and date_default_timezone_set($ip_geolocation_data['timezone'])) {
//Again, for redundancy.
ini_set("date.timezone", $ip_geolocation_data['timezone']);
} else {
ini_set("date.timezone", "UTC");
date_default_timezone_set("UTC");
$logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
}
}
} else {
/*
* This is here so that people don't come to us complaining and fill up the issue tracker when they put
* an incorrect timezone abbreviation in php.ini apparently.
*/
$timezone = ini_get("date.timezone");
if (strpos($timezone, "/") === false) {
$default_timezone = timezone_name_from_abbr($timezone);
ini_set("date.timezone", $default_timezone);
date_default_timezone_set($default_timezone);
} else {
date_default_timezone_set($timezone);
}