Changeset 1849172
- Timestamp:
- 03/29/2018 10:08:57 AM (8 years ago)
- Location:
- zoomd-search/trunk
- Files:
-
- 3 edited
-
classes/Core/Logger.php (modified) (5 diffs)
-
classes/zoomd_constants.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
zoomd-search/trunk/classes/Core/Logger.php
r1845082 r1849172 11 11 public $logLevel = 1; //0=info , 1=Warn , 2=Error 12 12 13 public function __construct(){ 14 $this->logLevel = defaultloglevel; 13 public function __construct(){ 14 $this->logLevel = defaultloglevel; 15 15 $lvl = get_transient('zoomd_loglevel'); 16 17 16 18 if(isset($lvl) && is_numeric($lvl)) 17 19 { … … 22 24 public function Info($msg){ 23 25 if($this->logLevel == 0) 24 $this->log($msg, "Info");26 $this->log($msg,3); 25 27 } 26 28 27 public function Warn($msg){ 29 public function Warn($msg){ 28 30 if($this->logLevel <= 1) 29 $this->log($msg, "Warn");31 $this->log($msg,4); 30 32 } 31 33 32 34 public function Error($msg){ 33 35 if($this->logLevel <= 2) 34 $this->log($msg, "Error");36 $this->log($msg,5); 35 37 } 36 38 37 public function log($msg,$level = "Info")39 public function log($msg,$level = 3) 38 40 { 39 41 try … … 42 44 if(!$this->isJson($msg)) 43 45 { 44 $data = array("message" => $msg , "level" => $level);46 $data = array("message" => $msg); 45 47 $data_string = json_encode($data); 46 48 } 47 $data_string = $this->enrichlogmsg($data_string); 48 49 $this->post_async(logglyUrl,$data_string); 49 $data_string = $this->enrichlogmsg($data_string,$level); 50 $this->post_async(loggerUrl,$data_string); 50 51 51 52 $siteUrl = Settings::siteUrl(); 52 if(defined( 'Zoomd_DBG' ) && (substr($siteUrl,0,strlen(localhost)) == localhost))53 {54 error_log($data_string);55 }56 // $this->post_async(localLogUrl, $data_string);57 53 } 58 54 catch (Exception $e) … … 64 60 private function post_async($url, $post_string) 65 61 { 66 //echo $post_string;62 $res = ""; 67 63 $parts=parse_url($url); 68 69 $fp = fsockopen($parts['host'], 70 isset($parts['port'])?$parts['port']:80, 71 $errno, $errstr, 30); 72 73 $out = "POST ".$parts['path']." HTTP/1.1\r\n"; 64 $fp = fsockopen("ssl://".$parts['host'],443,$errno, $errstr, 30); 65 66 $out = "POST ".$url." HTTP/1.1\r\n"; 74 67 $out.= "Host: ".$parts['host']."\r\n"; 75 68 $out.= "Content-Type: application/json\r\n"; … … 77 70 $out.= "Connection: Close\r\n\r\n"; 78 71 if (isset($post_string)) $out.= $post_string; 79 80 72 fwrite($fp, $out); 81 fclose($fp); 73 fclose($fp); 82 74 } 83 75 84 private function enrichlogmsg($msg )76 private function enrichlogmsg($msg,$lvl) 85 77 { 86 $jsonobj = json_decode($msg); 87 $jsonobj->siteid = Settings::siteId(); 88 $jsonobj->url = Settings::siteUrl(); 89 $jsonobj->clientid = Settings::clientId(); 90 $jsonobj->lastindexed = Settings::lastIndex(); 91 $jsonobj->environment = Settings::environment(); 92 $jsonobj->email = Settings::email(); 93 94 return json_encode($jsonobj); 78 $result = json_decode("{}"); 79 $result->privateKey = "98d36d56-a8ff-75a6-1fd2-389a76edf768"; 80 $result->applicationName = Settings::environment(); 81 $result->subsystemName = "Wordpress"; 82 $result->computerName = gethostname(); 83 84 $le = array( 85 array( 86 "timestamp" => microtime(true) * 1000, 87 "severity" => $lvl, 88 "siteid" => Settings::siteId(), 89 "url" => Settings::siteUrl(), 90 "clientid" => Settings::clientId(), 91 "lastindexed" => Settings::lastIndex(), 92 "environment" => Settings::environment(), 93 "email" => Settings::email(), 94 "text" => json_decode($msg) 95 ) 96 ); 97 98 $result->logEntries = $le; 99 return json_encode($result); 95 100 } 96 101 -
zoomd-search/trunk/classes/zoomd_constants.php
r1845082 r1849172 4 4 5 5 const baseURL = 'http://zadmin.zoomd.com'; 6 6 7 const widgetbaseURL = 'zsearch.zoomd.com'; 7 8 … … 19 20 const ValidationEndpoint = ValidateEndpointVal; 20 21 const RegistrationEndPoint = RegistrationEndpointVal; 21 const logglyUrl = 'https://logs-01.loggly.com/bulk/2f471b20-4cdf-4a0b-ba5b-dcaeb14206d2/tag/WordPress'; 22 23 const loggerUrl = 'https://api.coralogix.com/api/v1/logs'; 22 24 23 25 -
zoomd-search/trunk/readme.txt
r1845082 r1849172 46 46 = 2.1.0.37 = 47 47 * 4.9.4 update 48 * General Improvements 48 49 * Bug Fixes 49 50
Note: See TracChangeset
for help on using the changeset viewer.