Commit 1bf3ea16 by HanSon

修改console输出

1 parent 3936b291
...@@ -88,8 +88,10 @@ class Server ...@@ -88,8 +88,10 @@ class Server
$this->statusNotify(); $this->statusNotify();
Console::log('开始初始化联系人'); Console::log('开始初始化联系人');
$this->initContact(); $this->initContact();
Console::log(sprintf("初始化联系人成功\n群数量: %d\n联系人数量: %d\n公众号数量: %d\n特殊号数量: %d", group()->count(), contact()->count(), official()->count(), Special::getInstance()->count())); Console::log('初始化联系人成功');
Console::log(sprintf("群数量: %d", group()->count()));
Console::log(sprintf("联系人数量: %d", contact()->count()));
Console::log(sprintf("公众号数量: %d", official()->count()));
MessageHandler::getInstance()->listen(); MessageHandler::getInstance()->listen();
} }
......
...@@ -107,7 +107,7 @@ class Sync ...@@ -107,7 +107,7 @@ class Sync
*/ */
public function debugMessage($retCode, $selector, $sleep = null) public function debugMessage($retCode, $selector, $sleep = null)
{ {
Console::log('[DEBUG] retcode:' . $retCode . ' selector:' . $selector); Console::log('retcode:' . $retCode . ' selector:' . $selector, Console::WARNING);
if($sleep){ if($sleep){
sleep($sleep); sleep($sleep);
......
...@@ -35,7 +35,7 @@ class Emoticon extends Message implements MediaInterface, MessageInterface ...@@ -35,7 +35,7 @@ class Emoticon extends Message implements MediaInterface, MessageInterface
$response = static::uploadMedia($username, $file); $response = static::uploadMedia($username, $file);
if (!$response) { if (!$response) {
Console::log("表情 {$file} 上传失败"); Console::log("表情 {$file} 上传失败", Console::WARNING);
return false; return false;
} }
...@@ -57,7 +57,7 @@ class Emoticon extends Message implements MediaInterface, MessageInterface ...@@ -57,7 +57,7 @@ class Emoticon extends Message implements MediaInterface, MessageInterface
$result = http()->json($url, $data, true); $result = http()->json($url, $data, true);
if ($result['BaseResponse']['Ret'] != 0) { if ($result['BaseResponse']['Ret'] != 0) {
Console::log('发送表情失败'); Console::log('发送表情失败', Console::WARNING);
return false; return false;
} }
......
...@@ -31,9 +31,9 @@ class GroupChange extends Message implements MessageInterface ...@@ -31,9 +31,9 @@ class GroupChange extends Message implements MessageInterface
{ {
if(str_contains($this->msg['Content'], '加入了群聊')){ if(str_contains($this->msg['Content'], '加入了群聊')){
$this->action = 'ADD'; $this->action = 'ADD';
Console::log("检测到 {$this->from['NickName']} 有新成员,正在刷新群成员列表..."); Console::debug("检测到 {$this->from['NickName']} 有新成员,正在刷新群成员列表...");
(new ContactFactory())->makeContactList(); (new ContactFactory())->makeContactList();
Console::log('群成员更新成功!'); Console::debug('群成员更新成功!');
}elseif(str_contains($this->msg['Content'], '移出了群聊')){ }elseif(str_contains($this->msg['Content'], '移出了群聊')){
$this->action = 'REMOVE'; $this->action = 'REMOVE';
}elseif(str_contains($this->msg['Content'], '改群名为')){ }elseif(str_contains($this->msg['Content'], '改群名为')){
......
...@@ -42,7 +42,7 @@ class Image extends Message implements MessageInterface, MediaInterface ...@@ -42,7 +42,7 @@ class Image extends Message implements MessageInterface, MediaInterface
$response = static::uploadMedia($username, $file); $response = static::uploadMedia($username, $file);
if (!$response) { if (!$response) {
Console::log("文件 {$file} 上传失败"); Console::log("文件 {$file} 上传失败", Console::WARNING);
return false; return false;
} }
...@@ -63,7 +63,7 @@ class Image extends Message implements MessageInterface, MediaInterface ...@@ -63,7 +63,7 @@ class Image extends Message implements MessageInterface, MediaInterface
$result = http()->json($url, $data, true); $result = http()->json($url, $data, true);
if ($result['BaseResponse']['Ret'] != 0) { if ($result['BaseResponse']['Ret'] != 0) {
Console::log('发送图片失败'); Console::log('发送图片失败', Console::WARNING);
return false; return false;
} }
......
...@@ -24,8 +24,8 @@ class NewFriend extends Message implements MessageInterface ...@@ -24,8 +24,8 @@ class NewFriend extends Message implements MessageInterface
public function make() public function make()
{ {
Console::log('检测到新加好友,正在刷新好友列表...'); Console::debug('检测到新加好友,正在刷新好友列表...');
(new ContactFactory())->makeContactList(); (new ContactFactory())->makeContactList();
Console::log('好友更新成功!'); Console::debug('好友更新成功!');
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -58,7 +58,7 @@ class Text extends Message implements MessageInterface ...@@ -58,7 +58,7 @@ class Text extends Message implements MessageInterface
); );
if ($result['BaseResponse']['Ret'] != 0) { if ($result['BaseResponse']['Ret'] != 0) {
Console::log('发送消息失败'); Console::log('发送消息失败', Console::WARNING);
return false; return false;
} }
......
...@@ -34,7 +34,7 @@ class Video extends Message implements MessageInterface, MediaInterface ...@@ -34,7 +34,7 @@ class Video extends Message implements MessageInterface, MediaInterface
$response = static::uploadMedia($username, $file); $response = static::uploadMedia($username, $file);
if (!$response) { if (!$response) {
Console::log("视频 {$file} 上传失败"); Console::log("视频 {$file} 上传失败", Console::WARNING);
return false; return false;
} }
...@@ -55,7 +55,7 @@ class Video extends Message implements MessageInterface, MediaInterface ...@@ -55,7 +55,7 @@ class Video extends Message implements MessageInterface, MediaInterface
$result = http()->json($url, $data, true); $result = http()->json($url, $data, true);
if ($result['BaseResponse']['Ret'] != 0) { if ($result['BaseResponse']['Ret'] != 0) {
Console::log('发送视频失败'); Console::log('发送视频失败', Console::WARNING);
return false; return false;
} }
...@@ -90,7 +90,8 @@ class Video extends Message implements MessageInterface, MediaInterface ...@@ -90,7 +90,8 @@ class Video extends Message implements MessageInterface, MediaInterface
] ]
]); ]);
if(strlen($content) === 0){ if(strlen($content) === 0){
Console::log('下载视频失败', Console::ERROR); Console::log('下载视频失败', Console::WARNING);
Console::log('url:'. $url);
}else{ }else{
FileManager::download($this->msg['MsgId'] . '.mp4', $content, static::$folder); FileManager::download($this->msg['MsgId'] . '.mp4', $content, static::$folder);
} }
......
...@@ -79,7 +79,7 @@ trait UploadAble ...@@ -79,7 +79,7 @@ trait UploadAble
$response = static::uploadMedia($username, $file); $response = static::uploadMedia($username, $file);
if(!$response){ if(!$response){
Console::log("文件 {$file} 上传失败"); Console::log("文件 {$file} 上传失败", Console::WARNING);
return false; return false;
} }
...@@ -100,7 +100,7 @@ trait UploadAble ...@@ -100,7 +100,7 @@ trait UploadAble
$result = http()->json($url, $data, true); $result = http()->json($url, $data, true);
if($result['BaseResponse']['Ret'] != 0){ if($result['BaseResponse']['Ret'] != 0){
Console::log('发送文件失败'); Console::log('发送文件失败', Console::WARNING);
return false; return false;
} }
......
...@@ -34,6 +34,18 @@ class Console ...@@ -34,6 +34,18 @@ class Console
} }
/** /**
* debug 模式下调试输出
*
* @param $str
*/
public static function debug($str)
{
if (server()->config['debug']) {
static::log($str, 'DEBUG');
}
}
/**
* 初始化二维码style * 初始化二维码style
* *
* @param OutputInterface $output * @param OutputInterface $output
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!