Browse Source

Revert "Add monolog"

tags/2019.03^2
Hypolite Petovan 6 months ago
parent
commit
2f49c4a058

+ 1
- 4
bin/auth_ejabberd.php View File

@@ -34,7 +34,6 @@
34 34
 
35 35
 use Friendica\App;
36 36
 use Friendica\Util\ExAuth;
37
-use Friendica\Util\LoggerFactory;
38 37
 
39 38
 if (sizeof($_SERVER["argv"]) == 0) {
40 39
 	die();
@@ -52,9 +51,7 @@ chdir($directory);
52 51
 
53 52
 require dirname(__DIR__) . '/vendor/autoload.php';
54 53
 
55
-$logger = LoggerFactory::create('auth_ejabberd');
56
-
57
-$a = new App(dirname(__DIR__), $logger);
54
+$a = new App(dirname(__DIR__));
58 55
 
59 56
 if ($a->getMode()->isNormal()) {
60 57
 	$oAuth = new ExAuth();

+ 1
- 5
bin/console.php View File

@@ -3,11 +3,7 @@
3 3
 
4 4
 require dirname(__DIR__) . '/vendor/autoload.php';
5 5
 
6
-use Friendica\Util\LoggerFactory;
7
-
8
-$logger = LoggerFactory::create('console');
9
-
10
-$a = new Friendica\App(dirname(__DIR__), $logger);
6
+$a = new Friendica\App(dirname(__DIR__));
11 7
 \Friendica\BaseObject::setApp($a);
12 8
 
13 9
 (new Friendica\Core\Console($argv))->execute();

+ 8
- 10
bin/daemon.php View File

@@ -9,9 +9,9 @@
9 9
 
10 10
 use Friendica\App;
11 11
 use Friendica\Core\Config;
12
+use Friendica\Core\Logger;
12 13
 use Friendica\Core\Worker;
13 14
 use Friendica\Database\DBA;
14
-use Friendica\Util\LoggerFactory;
15 15
 
16 16
 // Get options
17 17
 $shortopts = 'f';
@@ -32,9 +32,7 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
32 32
 
33 33
 require dirname(__DIR__) . '/vendor/autoload.php';
34 34
 
35
-$logger = LoggerFactory::create('daemon');
36
-
37
-$a = new App(dirname(__DIR__), $logger);
35
+$a = new App(dirname(__DIR__));
38 36
 
39 37
 if ($a->getMode()->isInstall()) {
40 38
 	die("Friendica isn't properly installed yet.\n");
@@ -104,7 +102,7 @@ if ($mode == "stop") {
104 102
 
105 103
 	unlink($pidfile);
106 104
 
107
-	$logger->notice("Worker daemon process was killed", ["pid" => $pid]);
105
+	Logger::log("Worker daemon process $pid was killed.", Logger::DEBUG);
108 106
 
109 107
 	Config::set('system', 'worker_daemon_mode', false);
110 108
 	die("Worker daemon process $pid was killed.\n");
@@ -114,7 +112,7 @@ if (!empty($pid) && posix_kill($pid, 0)) {
114 112
 	die("Daemon process $pid is already running.\n");
115 113
 }
116 114
 
117
-$logger->notice('Starting worker daemon.', ["pid" => $pid]);
115
+Logger::log('Starting worker daemon.', Logger::DEBUG);
118 116
 
119 117
 if (!$foreground) {
120 118
 	echo "Starting worker daemon.\n";
@@ -162,7 +160,7 @@ $last_cron = 0;
162 160
 // Now running as a daemon.
163 161
 while (true) {
164 162
 	if (!$do_cron && ($last_cron + $wait_interval) < time()) {
165
-		$logger->info('Forcing cron worker call.', ["pid" => $pid]);
163
+		Logger::log('Forcing cron worker call.', Logger::DEBUG);
166 164
 		$do_cron = true;
167 165
 	}
168 166
 
@@ -176,7 +174,7 @@ while (true) {
176 174
 		$last_cron = time();
177 175
 	}
178 176
 
179
-	$logger->info("Sleeping", ["pid" => $pid]);
177
+	Logger::log("Sleeping", Logger::DEBUG);
180 178
 	$start = time();
181 179
 	do {
182 180
 		$seconds = (time() - $start);
@@ -193,10 +191,10 @@ while (true) {
193 191
 
194 192
 	if ($timeout) {
195 193
 		$do_cron = true;
196
-		$logger->info("Woke up after $wait_interval seconds.", ["pid" => $pid, 'sleep' => $wait_interval]);
194
+		Logger::log("Woke up after $wait_interval seconds.", Logger::DEBUG);
197 195
 	} else {
198 196
 		$do_cron = false;
199
-		$logger->info("Worker jobs are calling to be forked.", ["pid" => $pid]);
197
+		Logger::log("Worker jobs are calling to be forked.", Logger::DEBUG);
200 198
 	}
201 199
 }
202 200
 

+ 1
- 4
bin/worker.php View File

@@ -8,7 +8,6 @@ use Friendica\App;
8 8
 use Friendica\Core\Config;
9 9
 use Friendica\Core\Worker;
10 10
 use Friendica\Core\Update;
11
-use Friendica\Util\LoggerFactory;
12 11
 
13 12
 // Get options
14 13
 $shortopts = 'sn';
@@ -29,9 +28,7 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
29 28
 
30 29
 require dirname(__DIR__) . '/vendor/autoload.php';
31 30
 
32
-$logger = LoggerFactory::create('worker');
33
-
34
-$a = new App(dirname(__DIR__), $logger);
31
+$a = new App(dirname(__DIR__));
35 32
 
36 33
 // Check the database structure and possibly fixes it
37 34
 Update::check(true);

+ 1
- 2
composer.json View File

@@ -42,8 +42,7 @@
42 42
 		"npm-asset/jgrowl": "^1.4",
43 43
 		"npm-asset/fullcalendar": "^3.0.1",
44 44
 		"npm-asset/cropperjs": "1.2.2",
45
-		"npm-asset/imagesloaded": "4.1.4",
46
-		"monolog/monolog": "^1.24"
45
+		"npm-asset/imagesloaded": "4.1.4"
47 46
 	},
48 47
 	"repositories": [
49 48
 		{

+ 2
- 126
composer.lock View File

@@ -4,7 +4,7 @@
4 4
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 5
         "This file is @generated automatically"
6 6
     ],
7
-    "content-hash": "8cf7268fbcae8a22a518b9e7727eab84",
7
+    "content-hash": "51f7b3ab622038d7ef62ed03c06b48d0",
8 8
     "packages": [
9 9
         {
10 10
             "name": "asika/simple-console",
@@ -809,84 +809,6 @@
809 809
             ],
810 810
             "time": "2018-09-01T15:05:15+00:00"
811 811
         },
812
-        {
813
-            "name": "monolog/monolog",
814
-            "version": "1.24.0",
815
-            "source": {
816
-                "type": "git",
817
-                "url": "https://github.com/Seldaek/monolog.git",
818
-                "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
819
-            },
820
-            "dist": {
821
-                "type": "zip",
822
-                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
823
-                "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
824
-                "shasum": ""
825
-            },
826
-            "require": {
827
-                "php": ">=5.3.0",
828
-                "psr/log": "~1.0"
829
-            },
830
-            "provide": {
831
-                "psr/log-implementation": "1.0.0"
832
-            },
833
-            "require-dev": {
834
-                "aws/aws-sdk-php": "^2.4.9 || ^3.0",
835
-                "doctrine/couchdb": "~1.0@dev",
836
-                "graylog2/gelf-php": "~1.0",
837
-                "jakub-onderka/php-parallel-lint": "0.9",
838
-                "php-amqplib/php-amqplib": "~2.4",
839
-                "php-console/php-console": "^3.1.3",
840
-                "phpunit/phpunit": "~4.5",
841
-                "phpunit/phpunit-mock-objects": "2.3.0",
842
-                "ruflin/elastica": ">=0.90 <3.0",
843
-                "sentry/sentry": "^0.13",
844
-                "swiftmailer/swiftmailer": "^5.3|^6.0"
845
-            },
846
-            "suggest": {
847
-                "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
848
-                "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
849
-                "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
850
-                "ext-mongo": "Allow sending log messages to a MongoDB server",
851
-                "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
852
-                "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
853
-                "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
854
-                "php-console/php-console": "Allow sending log messages to Google Chrome",
855
-                "rollbar/rollbar": "Allow sending log messages to Rollbar",
856
-                "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
857
-                "sentry/sentry": "Allow sending log messages to a Sentry server"
858
-            },
859
-            "type": "library",
860
-            "extra": {
861
-                "branch-alias": {
862
-                    "dev-master": "2.0.x-dev"
863
-                }
864
-            },
865
-            "autoload": {
866
-                "psr-4": {
867
-                    "Monolog\\": "src/Monolog"
868
-                }
869
-            },
870
-            "notification-url": "https://packagist.org/downloads/",
871
-            "license": [
872
-                "MIT"
873
-            ],
874
-            "authors": [
875
-                {
876
-                    "name": "Jordi Boggiano",
877
-                    "email": "j.boggiano@seld.be",
878
-                    "homepage": "http://seld.be"
879
-                }
880
-            ],
881
-            "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
882
-            "homepage": "http://github.com/Seldaek/monolog",
883
-            "keywords": [
884
-                "log",
885
-                "logging",
886
-                "psr-3"
887
-            ],
888
-            "time": "2018-11-05T09:00:11+00:00"
889
-        },
890 812
         {
891 813
             "name": "npm-asset/cropperjs",
892 814
             "version": "1.2.2",
@@ -1888,53 +1810,6 @@
1888 1810
             ],
1889 1811
             "time": "2016-08-06T14:39:51+00:00"
1890 1812
         },
1891
-        {
1892
-            "name": "psr/log",
1893
-            "version": "1.1.0",
1894
-            "source": {
1895
-                "type": "git",
1896
-                "url": "https://github.com/php-fig/log.git",
1897
-                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
1898
-            },
1899
-            "dist": {
1900
-                "type": "zip",
1901
-                "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
1902
-                "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
1903
-                "shasum": ""
1904
-            },
1905
-            "require": {
1906
-                "php": ">=5.3.0"
1907
-            },
1908
-            "type": "library",
1909
-            "extra": {
1910
-                "branch-alias": {
1911
-                    "dev-master": "1.0.x-dev"
1912
-                }
1913
-            },
1914
-            "autoload": {
1915
-                "psr-4": {
1916
-                    "Psr\\Log\\": "Psr/Log/"
1917
-                }
1918
-            },
1919
-            "notification-url": "https://packagist.org/downloads/",
1920
-            "license": [
1921
-                "MIT"
1922
-            ],
1923
-            "authors": [
1924
-                {
1925
-                    "name": "PHP-FIG",
1926
-                    "homepage": "http://www.php-fig.org/"
1927
-                }
1928
-            ],
1929
-            "description": "Common interface for logging libraries",
1930
-            "homepage": "https://github.com/php-fig/log",
1931
-            "keywords": [
1932
-                "log",
1933
-                "psr",
1934
-                "psr-3"
1935
-            ],
1936
-            "time": "2018-11-20T15:27:04+00:00"
1937
-        },
1938 1813
         {
1939 1814
             "name": "seld/cli-prompt",
1940 1815
             "version": "1.0.3",
@@ -2606,6 +2481,7 @@
2606 2481
                 "testing",
2607 2482
                 "xunit"
2608 2483
             ],
2484
+            "abandoned": true,
2609 2485
             "time": "2016-12-02T14:39:14+00:00"
2610 2486
         },
2611 2487
         {

+ 37
- 41
include/api.php View File

@@ -55,8 +55,6 @@ define('API_METHOD_GET', 'GET');
55 55
 define('API_METHOD_POST', 'POST,PUT');
56 56
 define('API_METHOD_DELETE', 'POST,DELETE');
57 57
 
58
-define('API_LOG_PREFIX', 'API {action} - ');
59
-
60 58
 $API = [];
61 59
 $called_api = [];
62 60
 
@@ -99,9 +97,9 @@ function api_source()
99 97
 			return "Twidere";
100 98
 		}
101 99
 
102
-		Logger::info(API_LOG_PREFIX . 'Unrecognized user-agent', ['module' => 'api', 'action' => 'source', 'http_user_agent' => $_SERVER['HTTP_USER_AGENT']]);
100
+		Logger::log("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], Logger::DEBUG);
103 101
 	} else {
104
-		Logger::info(API_LOG_PREFIX . 'Empty user-agent', ['module' => 'api', 'action' => 'source']);
102
+		Logger::log("Empty user-agent", Logger::DEBUG);
105 103
 	}
106 104
 
107 105
 	return "api";
@@ -183,7 +181,7 @@ function api_login(App $a)
183 181
 		var_dump($consumer, $token);
184 182
 		die();
185 183
 	} catch (Exception $e) {
186
-		Logger::warning(API_LOG_PREFIX . 'error', ['module' => 'api', 'action' => 'login', 'exception' => $e->getMessage()]);
184
+		Logger::log($e);
187 185
 	}
188 186
 
189 187
 	// workaround for HTTP-auth in CGI mode
@@ -197,7 +195,7 @@ function api_login(App $a)
197 195
 	}
198 196
 
199 197
 	if (empty($_SERVER['PHP_AUTH_USER'])) {
200
-		Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
198
+		Logger::log('API_login: ' . print_r($_SERVER, true), Logger::DEBUG);
201 199
 		header('WWW-Authenticate: Basic realm="Friendica"');
202 200
 		throw new UnauthorizedException("This API requires login");
203 201
 	}
@@ -238,7 +236,7 @@ function api_login(App $a)
238 236
 	}
239 237
 
240 238
 	if (!DBA::isResult($record)) {
241
-		Logger::debug(API_LOG_PREFIX . 'failed', ['module' => 'api', 'action' => 'login', 'parameters' => $_SERVER]);
239
+		Logger::log('API_login failure: ' . print_r($_SERVER, true), Logger::DEBUG);
242 240
 		header('WWW-Authenticate: Basic realm="Friendica"');
243 241
 		//header('HTTP/1.0 401 Unauthorized');
244 242
 		//die('This api requires login');
@@ -311,35 +309,33 @@ function api_call(App $a)
311 309
 					api_login($a);
312 310
 				}
313 311
 
314
-				Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username']]);
315
-				Logger::debug(API_LOG_PREFIX . 'parameters', ['module' => 'api', 'action' => 'call', 'parameters' => $_REQUEST]);
312
+				Logger::log('API call for ' . $a->user['username'] . ': ' . $a->query_string);
313
+				Logger::log('API parameters: ' . print_r($_REQUEST, true));
316 314
 
317 315
 				$stamp =  microtime(true);
318 316
 				$return = call_user_func($info['func'], $type);
319 317
 				$duration = (float) (microtime(true) - $stamp);
320
-
321
-				Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);
318
+				Logger::log("API call duration: " . round($duration, 2) . "\t" . $a->query_string, Logger::DEBUG);
322 319
 
323 320
 				if (Config::get("system", "profiler")) {
324 321
 					$duration = microtime(true)-$a->performance["start"];
325 322
 
326 323
 					/// @TODO round() really everywhere?
327
-					Logger::debug(
328
-						API_LOG_PREFIX . 'performance',
329
-						[
330
-							'module' => 'api',
331
-							'action' => 'call',
332
-							'database_read' => round($a->performance["database"] - $a->performance["database_write"], 3),
333
-							'database_write' => round($a->performance["database_write"], 3),
334
-							'cache_read' => round($a->performance["cache"], 3),
335
-							'cache_write' => round($a->performance["cache_write"], 3),
336
-							'network_io' => round($a->performance["network"], 2),
337
-							'file_io' => round($a->performance["file"], 2),
338
-							'other_io' => round($duration - ($a->performance["database"]
339
-									+ $a->performance["cache"] + $a->performance["cache_write"]
340
-									+ $a->performance["network"] + $a->performance["file"]), 2),
341
-							'total' => round($duration, 2)
342
-						]
324
+					Logger::log(
325
+						parse_url($a->query_string, PHP_URL_PATH) . ": " . sprintf(
326
+							"Database: %s/%s, Cache %s/%s, Network: %s, I/O: %s, Other: %s, Total: %s",
327
+							round($a->performance["database"] - $a->performance["database_write"], 3),
328
+							round($a->performance["database_write"], 3),
329
+							round($a->performance["cache"], 3),
330
+							round($a->performance["cache_write"], 3),
331
+							round($a->performance["network"], 2),
332
+							round($a->performance["file"], 2),
333
+							round($duration - ($a->performance["database"]
334
+								+ $a->performance["cache"] + $a->performance["cache_write"]
335
+								+ $a->performance["network"] + $a->performance["file"]), 2),
336
+							round($duration, 2)
337
+						),
338
+						Logger::DEBUG
343 339
 					);
344 340
 
345 341
 					if (Config::get("rendertime", "callstack")) {
@@ -380,7 +376,7 @@ function api_call(App $a)
380 376
 								$o .= $func . ": " . $time . "\n";
381 377
 							}
382 378
 						}
383
-						Logger::debug(API_LOG_PREFIX . $o, ['module' => 'api', 'action' => 'call']);
379
+						Logger::log($o, Logger::DEBUG);
384 380
 					}
385 381
 				}
386 382
 
@@ -417,7 +413,7 @@ function api_call(App $a)
417 413
 			}
418 414
 		}
419 415
 
420
-		Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call']);
416
+		Logger::log('API call not implemented: ' . $a->query_string);
421 417
 		throw new NotImplementedException();
422 418
 	} catch (HTTPException $e) {
423 419
 		header("HTTP/1.1 {$e->httpcode} {$e->httpdesc}");
@@ -526,7 +522,7 @@ function api_get_user(App $a, $contact_id = null)
526 522
 	$extra_query = "";
527 523
 	$url = "";
528 524
 
529
-	Logger::info(API_LOG_PREFIX . 'Fetching data for user {user}', ['module' => 'api', 'action' => 'get_user', 'user' => $contact_id]);
525
+	Logger::log("api_get_user: Fetching user data for user ".$contact_id, Logger::DEBUG);
530 526
 
531 527
 	// Searching for contact URL
532 528
 	if (!is_null($contact_id) && (intval($contact_id) == 0)) {
@@ -610,7 +606,7 @@ function api_get_user(App $a, $contact_id = null)
610 606
 		}
611 607
 	}
612 608
 
613
-	Logger::info(API_LOG_PREFIX . 'getting user {user}', ['module' => 'api', 'action' => 'get_user', 'user' => $user]);
609
+	Logger::log("api_get_user: user ".$user, Logger::DEBUG);
614 610
 
615 611
 	if (!$user) {
616 612
 		if (api_user() === false) {
@@ -622,7 +618,7 @@ function api_get_user(App $a, $contact_id = null)
622 618
 		}
623 619
 	}
624 620
 
625
-	Logger::info(API_LOG_PREFIX . 'found user {user}', ['module' => 'api', 'action' => 'get_user', 'user' => $user, 'extra_query' => $extra_query]);
621
+	Logger::log('api_user: ' . $extra_query . ', user: ' . $user);
626 622
 
627 623
 	// user info
628 624
 	$uinfo = q(
@@ -1941,7 +1937,7 @@ function api_conversation_show($type)
1941 1937
 		$id = intval(defaults($a->argv, 4, 0));
1942 1938
 	}
1943 1939
 
1944
-	Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
1940
+	Logger::log('API: api_conversation_show: '.$id);
1945 1941
 
1946 1942
 	// try to fetch the item for the local user - or the public item, if there is no local one
1947 1943
 	$item = Item::selectFirst(['parent-uri'], ['id' => $id]);
@@ -2335,7 +2331,7 @@ function api_favorites($type)
2335 2331
 
2336 2332
 	// in friendica starred item are private
2337 2333
 	// return favorites only for self
2338
-	Logger::info(API_LOG_PREFIX . 'for {self}', ['module' => 'api', 'action' => 'favorites', 'self' => $user_info['self']]);
2334
+	Logger::log('api_favorites: self:' . $user_info['self']);
2339 2335
 
2340 2336
 	if ($user_info['self'] == 0) {
2341 2337
 		$ret = [];
@@ -3698,7 +3694,7 @@ function api_friendships_destroy($type)
3698 3694
 	$contact_id = defaults($_REQUEST, 'user_id');
3699 3695
 
3700 3696
 	if (empty($contact_id)) {
3701
-		Logger::notice(API_LOG_PREFIX . 'No user_id specified', ['module' => 'api', 'action' => 'friendships_destroy']);
3697
+		Logger::log("No user_id specified", Logger::DEBUG);
3702 3698
 		throw new BadRequestException("no user_id specified");
3703 3699
 	}
3704 3700
 
@@ -3706,7 +3702,7 @@ function api_friendships_destroy($type)
3706 3702
 	$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => 0, 'self' => false]);
3707 3703
 
3708 3704
 	if(!DBA::isResult($contact)) {
3709
-		Logger::notice(API_LOG_PREFIX . 'No contact found for ID {contact}', ['module' => 'api', 'action' => 'friendships_destroy', 'contact' => $contact_id]);
3705
+		Logger::log("No contact found for ID" . $contact_id, Logger::DEBUG);
3710 3706
 		throw new NotFoundException("no contact found to given ID");
3711 3707
 	}
3712 3708
 
@@ -3718,12 +3714,12 @@ function api_friendships_destroy($type)
3718 3714
 	$contact = DBA::selectFirst('contact', [], $condition);
3719 3715
 
3720 3716
 	if (!DBA::isResult($contact)) {
3721
-		Logger::notice(API_LOG_PREFIX . 'Not following contact', ['module' => 'api', 'action' => 'friendships_destroy']);
3717
+		Logger::log("Not following Contact", Logger::DEBUG);
3722 3718
 		throw new NotFoundException("Not following Contact");
3723 3719
 	}
3724 3720
 
3725 3721
 	if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
3726
-		Logger::notice(API_LOG_PREFIX . 'Not supported for {network}', ['module' => 'api', 'action' => 'friendships_destroy', 'network' => $contact['network']]);
3722
+		Logger::log("Not supported", Logger::DEBUG);
3727 3723
 		throw new ExpectationFailedException("Not supported");
3728 3724
 	}
3729 3725
 
@@ -3734,7 +3730,7 @@ function api_friendships_destroy($type)
3734 3730
 		Contact::terminateFriendship($owner, $contact, $dissolve);
3735 3731
 	}
3736 3732
 	else {
3737
-		Logger::notice(API_LOG_PREFIX . 'No owner {uid} found', ['module' => 'api', 'action' => 'friendships_destroy', 'uid' => $uid]);
3733
+		Logger::log("No owner found", Logger::DEBUG);
3738 3734
 		throw new NotFoundException("Error Processing Request");
3739 3735
 	}
3740 3736
 
@@ -4841,7 +4837,7 @@ function api_friendica_remoteauth()
4841 4837
 		'sec' => $sec, 'expire' => time() + 45];
4842 4838
 	DBA::insert('profile_check', $fields);
4843 4839
 
4844
-	Logger::info(API_LOG_PREFIX . 'for contact {contact}', ['module' => 'api', 'action' => 'friendica_remoteauth', 'contact' => $contact['name'], 'hey' => $sec]);
4840
+	Logger::log($contact['name'] . ' ' . $sec, Logger::DEBUG);
4845 4841
 	$dest = ($url ? '&destination_url=' . $url : '');
4846 4842
 
4847 4843
 	System::externalRedirect(
@@ -5090,7 +5086,7 @@ function api_in_reply_to($item)
5090 5086
 		// https://github.com/friendica/friendica/issues/1010
5091 5087
 		// This is a bugfix for that.
5092 5088
 		if (intval($in_reply_to['status_id']) == intval($item['id'])) {
5093
-			Logger::warning(API_LOG_PREFIX . 'ID {id} is similar to reply-to {reply-to}', ['module' => 'api', 'action' => 'in_reply_to', 'id' => $item['id'], 'reply-to' => $in_reply_to['status_id']]);
5089
+			Logger::log('this message should never appear: id: '.$item['id'].' similar to reply-to: '.$in_reply_to['status_id'], Logger::DEBUG);
5094 5090
 			$in_reply_to['status_id'] = null;
5095 5091
 			$in_reply_to['user_id'] = null;
5096 5092
 			$in_reply_to['status_id_str'] = null;

+ 2
- 4
index.php View File

@@ -5,7 +5,6 @@
5 5
  */
6 6
 
7 7
 use Friendica\App;
8
-use Friendica\Util\LoggerFactory;
9 8
 
10 9
 if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
11 10
 	die('Vendor path not found. Please execute "bin/composer.phar --no-dev install" on the command line in the web root.');
@@ -13,10 +12,9 @@ if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
13 12
 
14 13
 require __DIR__ . '/vendor/autoload.php';
15 14
 
16
-$logger = LoggerFactory::create('index');
17
-
18 15
 // We assume that the index.php is called by a frontend process
19 16
 // The value is set to "true" by default in App
20
-$a = new App(__DIR__, $logger, false);
17
+$a = new App(__DIR__, false);
21 18
 
22 19
 $a->runFrontend();
20
+

+ 1
- 1
mod/acl.php View File

@@ -34,7 +34,7 @@ function acl_content(App $a)
34 34
 		$search = $_REQUEST['query'];
35 35
 	}
36 36
 
37
-	Logger::info('ACL {action} - {subaction}', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
37
+	Logger::log("Searching for ".$search." - type ".$type." conversation ".$conv_id, Logger::DEBUG);
38 38
 
39 39
 	if ($search != '') {
40 40
 		$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";

+ 3
- 30
src/App.php View File

@@ -8,10 +8,8 @@ use Detection\MobileDetect;
8 8
 use DOMDocument;
9 9
 use DOMXPath;
10 10
 use Exception;
11
-use Friendica\Core\Logger;
12 11
 use Friendica\Database\DBA;
13 12
 use Friendica\Network\HTTPException\InternalServerErrorException;
14
-use Psr\Log\LoggerInterface;
15 13
 
16 14
 /**
17 15
  *
@@ -108,11 +106,6 @@ class App
108 106
 	 */
109 107
 	public $mobileDetect;
110 108
 
111
-	/**
112
-	 * @var LoggerInterface The current logger of this App
113
-	 */
114
-	private $logger;
115
-
116 109
 	/**
117 110
 	 * Register a stylesheet file path to be included in the <head> tag of every page.
118 111
 	 * Inclusion is done in App->initHead().
@@ -153,16 +146,13 @@ class App
153 146
 	/**
154 147
 	 * @brief App constructor.
155 148
 	 *
156
-	 * @param string           $basePath  Path to the app base folder
157
-	 * @param LoggerInterface  $logger    Logger of this application
158
-	 * @param bool             $isBackend Whether it is used for backend or frontend (Default true=backend)
149
+	 * @param string $basePath  Path to the app base folder
150
+	 * @param bool   $isBackend Whether it is used for backend or frontend (Default true=backend)
159 151
 	 *
160 152
 	 * @throws Exception if the Basepath is not usable
161 153
 	 */
162
-	public function __construct($basePath, LoggerInterface $logger, $isBackend = true)
154
+	public function __construct($basePath, $isBackend = true)
163 155
 	{
164
-		$this->logger = $logger;
165
-
166 156
 		if (!static::isDirectoryUsable($basePath, false)) {
167 157
 			throw new Exception('Basepath ' . $basePath . ' isn\'t usable.');
168 158
 		}
@@ -311,21 +301,6 @@ class App
311 301
 		return $this->mode;
312 302
 	}
313 303
 
314
-	/**
315
-	 * Returns the Logger of the Application
316
-	 *
317
-	 * @return LoggerInterface The Logger
318
-	 * @throws InternalServerErrorException when the logger isn't created
319
-	 */
320
-	public function getLogger()
321
-	{
322
-		if (empty($this->logger)) {
323
-			throw new InternalServerErrorException('Logger of the Application is not defined');
324
-		}
325
-
326
-		return $this->logger;
327
-	}
328
-
329 304
 	/**
330 305
 	 * Reloads the whole app instance
331 306
 	 */
@@ -353,8 +328,6 @@ class App
353 328
 		Core\L10n::init();
354 329
 
355 330
 		$this->process_id = Core\System::processID('log');
356
-
357
-		Core\Logger::setLogger($this->logger);
358 331
 	}
359 332
 
360 333
 	/**

+ 1
- 4
src/BaseObject.php View File

@@ -6,8 +6,6 @@ namespace Friendica;
6 6
 
7 7
 require_once 'boot.php';
8 8
 
9
-use Friendica\Util\LoggerFactory;
10
-
11 9
 /**
12 10
  * Basic object
13 11
  *
@@ -27,8 +25,7 @@ class BaseObject
27 25
 	public static function getApp()
28 26
 	{
29 27
 		if (empty(self::$app)) {
30
-			$logger = $logger = LoggerFactory::create('app');
31
-			self::$app = new App(dirname(__DIR__), $logger);
28
+			self::$app = new App(dirname(__DIR__));
32 29
 		}
33 30
 
34 31
 		return self::$app;

+ 6
- 5
src/Core/Addon.php View File

@@ -4,7 +4,9 @@
4 4
  */
5 5
 namespace Friendica\Core;
6 6
 
7
+use Friendica\App;
7 8
 use Friendica\BaseObject;
9
+use Friendica\Core\Logger;
8 10
 use Friendica\Database\DBA;
9 11
 
10 12
 /**
@@ -74,7 +76,7 @@ class Addon extends BaseObject
74 76
 	 */
75 77
 	public static function uninstall($addon)
76 78
 	{
77
-		Logger::notice("Addon {addon}: {action}", ['action' => 'uninstall', 'addon' => $addon]);
79
+		Logger::log("Addons: uninstalling " . $addon);
78 80
 		DBA::delete('addon', ['name' => $addon]);
79 81
 
80 82
 		@include_once('addon/' . $addon . '/' . $addon . '.php');
@@ -99,7 +101,7 @@ class Addon extends BaseObject
99 101
 		if (!file_exists('addon/' . $addon . '/' . $addon . '.php')) {
100 102
 			return false;
101 103
 		}
102
-		Logger::notice("Addon {addon}: {action}", ['action' => 'install', 'addon' => $addon]);
104
+		Logger::log("Addons: installing " . $addon);
103 105
 		$t = @filemtime('addon/' . $addon . '/' . $addon . '.php');
104 106
 		@include_once('addon/' . $addon . '/' . $addon . '.php');
105 107
 		if (function_exists($addon . '_install')) {
@@ -124,7 +126,7 @@ class Addon extends BaseObject
124 126
 			}
125 127
 			return true;
126 128
 		} else {
127
-			Logger::error("Addon {addon}: {action} failed", ['action' => 'uninstall', 'addon' => $addon]);
129
+			Logger::log("Addons: FAILED installing " . $addon);
128 130
 			return false;
129 131
 		}
130 132
 	}
@@ -154,8 +156,7 @@ class Addon extends BaseObject
154 156
 						$t = @filemtime($fname);
155 157
 						foreach ($installed as $i) {
156 158
 							if (($i['name'] == $addon) && ($i['timestamp'] != $t)) {
157
-
158
-								Logger::notice("Addon {addon}: {action}", ['action' => 'reload', 'addon' => $i['name']]);
159
+								Logger::log('Reloading addon: ' . $i['name']);
159 160
 								@include_once($fname);
160 161
 
161 162
 								if (function_exists($addon . '_uninstall')) {

+ 98
- 282
src/Core/Logger.php View File

@@ -5,297 +5,82 @@
5 5
 namespace Friendica\Core;
6 6
 
7 7
 use Friendica\BaseObject;
8
-use Friendica\Network\HTTPException\InternalServerErrorException;
9
-use Friendica\Util\LoggerFactory;
10
-use Psr\Log\LoggerInterface;
11
-use Psr\Log\LogLevel;
8
+use Friendica\Core\Config;
9
+use Friendica\Util\DateTimeFormat;
10
+use ReflectionClass;
12 11
 
13 12
 /**
14 13
  * @brief Logger functions
15 14
  */
16 15
 class Logger extends BaseObject
17 16
 {
18
-	/**
19
-	 * @see Logger::error()
20
-	 */
21
-	const WARNING = LogLevel::ERROR;
22
-	/**
23
-	 * @see Logger::warning()
24
-	 */
25
-	const INFO = LogLevel::WARNING;
26
-	/**
27
-	 * @see Logger::notice()
28
-	 */
29
-	const TRACE = LogLevel::NOTICE;
30
-	/**
31
-	 * @see Logger::info()
32
-	 */
33
-	const DEBUG = LogLevel::INFO;
34
-	/**
35
-	 * @see Logger::debug()
36
-	 */
37
-	const DATA = LogLevel::DEBUG;
38
-	/**
39
-	 * @see Logger::debug()
40
-	 */
41
-	const ALL = LogLevel::DEBUG;
42
-
43
-	/**
44
-	 * @var array the legacy loglevels
45
-	 * @deprecated 2019.03 use PSR-3 loglevels
46
-	 * @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel
47
-	 *
48
-	 */
49
-	public static $levels = [
50
-		self::WARNING => 'Warning',
51
-		self::INFO => 'Info',
52
-		self::TRACE => 'Trace',
53
-		self::DEBUG => 'Debug',
54
-		self::DATA => 'Data',
55
-		self::ALL => 'All',
56
-	];
57
-
58
-	/**
59
-	 * @var LoggerInterface A PSR-3 compliant logger instance
60
-	 */
61
-	private static $logger;
62
-
63
-	/**
64
-	 * @var LoggerInterface A PSR-3 compliant logger instance for developing only
65
-	 */
66
-	private static $devLogger;
67
-
68
-	/**
69
-	 * Sets the default logging handler for Friendica.
70
-	 * @todo Can be combined with other handlers too if necessary, could be configurable.
71
-	 *
72
-	 * @param LoggerInterface $logger The Logger instance of this Application
73
-	 *
74
-	 * @throws InternalServerErrorException if the logger factory is incompatible to this logger
75
-	 */
76
-	public static function setLogger($logger)
77
-	{
78
-		$debugging = Config::get('system', 'debugging');
79
-		$logfile = Config::get('system', 'logfile');
80
-		$loglevel = intval(Config::get('system', 'loglevel'));
81
-
82
-		if (!$debugging || !$logfile) {
83
-			return;
84
-		}
85
-
86
-		$level = self::mapPSR3Level($loglevel);
87
-		LoggerFactory::addStreamHandler($logger, $logfile, $level);
88
-
89
-		self::$logger = $logger;
90
-
91
-		$logfile = Config::get('system', 'dlogfile');
92
-
93
-		if (!$logfile) {
94
-			return;
95
-		}
96
-
97
-		$developIp = Config::get('system', 'dlogip');
98
-
99
-		self::$devLogger = LoggerFactory::createDev('develop', $developIp);
100
-		LoggerFactory::addStreamHandler(self::$devLogger, $logfile, LogLevel::DEBUG);
101
-	}
102
-
103
-	/**
104
-	 * System is unusable.
105
-	 * @see LoggerInterface::emergency()
106
-	 *
107
-	 * @param string $message
108
-	 * @param array  $context
109
-	 *
110
-	 * @return void
111
-	 *
112
-	 */
113
-	public static function emergency($message, $context = [])
114
-	{
115
-		if (!isset(self::$logger)) {
116
-			return;
117
-		}
118
-
119
-		$stamp1 = microtime(true);
120
-		self::$logger->emergency($message, $context);
121
-		self::getApp()->saveTimestamp($stamp1, 'file');
122
-	}
123
-
124
-	/**
125
-	 * Action must be taken immediately.
126
-	 * @see LoggerInterface::alert()
127
-	 *
128
-	 * Example: Entire website down, database unavailable, etc. This should
129
-	 * trigger the SMS alerts and wake you up.
130
-	 *
131
-	 * @param string $message
132
-	 * @param array  $context
133
-	 *
134
-	 * @return void
135
-	 *
136
-	 */
137
-	public static function alert($message, $context = [])
138
-	{
139
-		if (!isset(self::$logger)) {
140
-			return;
141
-		}
142
-
143
-		$stamp1 = microtime(true);
144
-		self::$logger->alert($message, $context);
145
-		self::getApp()->saveTimestamp($stamp1, 'file');
146
-	}
147
-
148
-	/**
149
-	 * Critical conditions.
150
-	 * @see LoggerInterface::critical()
151
-	 *
152
-	 * Example: Application component unavailable, unexpected exception.
153
-	 *
154
-	 * @param string $message
155
-	 * @param array  $context
156
-	 *
157
-	 * @return void
158
-	 *
159
-	 */
160
-	public static function critical($message, $context = [])
161
-	{
162
-		if (!isset(self::$logger)) {
163
-			return;
164
-		}
165
-
166
-		$stamp1 = microtime(true);
167
-		self::$logger->critical($message, $context);
168
-		self::getApp()->saveTimestamp($stamp1, 'file');
169
-	}
170
-
171
-	/**
172
-	 * Runtime errors that do not require immediate action but should typically
173
-	 * be logged and monitored.
174
-	 * @see LoggerInterface::error()
175
-	 *
176
-	 * @param string $message
177
-	 * @param array  $context
178
-	 *
179
-	 * @return void
180
-	 *
181
-	 */
182
-	public static function error($message, $context = [])
183
-	{
184
-		if (!isset(self::$logger)) {
185
-			echo "not set!?\n";
186
-			return;
187
-		}
188
-
189
-		$stamp1 = microtime(true);
190
-		self::$logger->error($message, $context);
191
-		self::getApp()->saveTimestamp($stamp1, 'file');
192
-	}
193
-
194
-	/**
195
-	 * Exceptional occurrences that are not errors.
196
-	 * @see LoggerInterface::warning()
197
-	 *
198
-	 * Example: Use of deprecated APIs, poor use of an API, undesirable things
199
-	 * that are not necessarily wrong.
200
-	 *
201
-	 * @param string $message
202
-	 * @param array  $context
203
-	 *
204
-	 * @return void
205
-	 *
206
-	 */
207
-	public static function warning($message, $context = [])
208
-	{
209
-		if (!isset(self::$logger)) {
210
-			return;
211
-		}
212
-
213
-		$stamp1 = microtime(true);
214
-		self::$logger->warning($message, $context);
215
-		self::getApp()->saveTimestamp($stamp1, 'file');
216
-	}
217
-
218
-	/**
219
-	 * Normal but significant events.
220
-	 * @see LoggerInterface::notice()
221
-	 *
222
-	 * @param string $message
223
-	 * @param array  $context
224
-	 *
225
-	 * @return void
226
-	 *
227
-	 */
228
-	public static function notice($message, $context = [])
229
-	{
230
-		if (!isset(self::$logger)) {
231
-			return;
232
-		}
233
-
234
-		$stamp1 = microtime(true);
235
-		self::$logger->notice($message, $context);
236
-		self::getApp()->saveTimestamp($stamp1, 'file');
237
-	}
238
-
239
-	/**
240
-	 * Interesting events.
241
-	 * @see LoggerInterface::info()
242
-	 *
243
-	 * Example: User logs in, SQL logs.
244
-	 *
245
-	 * @param string $message
246
-	 * @param array  $context
247
-	 *
248
-	 * @return void
249
-	 *
250
-	 */
251
-	public static function info($message, $context = [])
252
-	{
253
-		if (!isset(self::$logger)) {
254
-			return;
255
-		}
256
-
257
-		$stamp1 = microtime(true);
258
-		self::$logger->info($message, $context);
259
-		self::getApp()->saveTimestamp($stamp1, 'file');
260
-	}
261
-
262
-	/**
263
-	 * Detailed debug information.
264
-	 * @see LoggerInterface::debug()
265
-	 *
266
-	 * @param string $message
267
-	 * @param array  $context
268
-	 *
269
-	 * @return void
270
-	 */
271
-	public static function debug($message, $context = [])
272
-	{
273
-		if (!isset(self::$logger)) {
274
-			return;
275
-		}
276
-
277
-		$stamp1 = microtime(true);
278
-		self::$logger->debug($message, $context);
279
-		self::getApp()->saveTimestamp($stamp1, 'file');
280
-	}
17
+    // Log levels:
18
+    const WARNING = 0;
19
+    const INFO = 1;
20
+    const TRACE = 2;
21
+    const DEBUG = 3;
22
+    const DATA = 4;
23
+    const ALL = 5;
24
+
25
+    public static $levels = [
26
+        self::WARNING => 'Warning',
27
+        self::INFO => 'Info',
28
+        self::TRACE => 'Trace',
29
+        self::DEBUG => 'Debug',
30
+        self::DATA => 'Data',
31
+        self::ALL => 'All',
32
+    ];
281 33
 
282 34
     /**
283 35
      * @brief Logs the given message at the given log level
284 36
      *
285 37
      * @param string $msg
286 38
      * @param int $level
287
-	 *
288
-	 * @deprecated since 2019.03 Use Logger::debug() Logger::info() , ... instead
289 39
      */
290
-    public static function log($msg, $level = LogLevel::NOTICE)
40
+    public static function log($msg, $level = self::INFO)
291 41
     {
292
-		if (!isset(self::$logger)) {
293
-			return;
294
-		}
42
+        $a = self::getApp();
43
+
44
+        $debugging = Config::get('system', 'debugging');
45
+        $logfile   = Config::get('system', 'logfile');
46
+        $loglevel = intval(Config::get('system', 'loglevel'));
47
+
48
+        if (
49
+            !$debugging
50
+            || !$logfile
51
+            || $level > $loglevel
52
+        ) {
53
+            return;
54
+        }
55
+
56
+        $processId = session_id();
57
+
58
+        if ($processId == '')
59
+        {
60
+            $processId = $a->process_id;
61
+        }
62
+
63
+        $callers = debug_backtrace();
64
+
65
+        if (count($callers) > 1) {
66
+            $function = $callers[1]['function'];
67
+        } else {
68
+            $function = '';
69
+        }
70
+
71
+        $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
72
+                DateTimeFormat::utcNow(DateTimeFormat::ATOM),
73
+                $processId,
74
+                self::$levels[$level],
75
+                basename($callers[0]['file']),
76
+                $callers[0]['line'],
77
+                $function,
78
+                $msg
79
+            );
295 80
 
296 81
         $stamp1 = microtime(true);
297
-		self::$logger->log($level, $msg);
298
-        self::getApp()->saveTimestamp($stamp1, "file");
82
+        @file_put_contents($logfile, $logline, FILE_APPEND);
83
+        $a->saveTimestamp($stamp1, "file");
299 84
     }
300 85
 
301 86
     /**
@@ -305,16 +90,47 @@ class Logger extends BaseObject
305 90
      * personally without background noise
306 91
      *
307 92
      * @param string $msg
308
-	 * @param string $level
309 93
      */
310
-    public static function devLog($msg, $level = LogLevel::DEBUG)
94
+    public static function devLog($msg)
311 95
     {
312
-		if (!isset(self::$logger)) {
313
-			return;
314
-		}
96
+        $a = self::getApp();
97
+
98
+        $logfile = Config::get('system', 'dlogfile');
99
+
100
+        if (!$logfile) {
101
+            return;
102
+        }
103
+
104
+        $dlogip = Config::get('system', 'dlogip');
105
+
106
+        if (!is_null($dlogip) && $_SERVER['REMOTE_ADDR'] != $dlogip)
107
+        {
108
+            return;
109
+        }
110
+
111
+        $processId = session_id();
112
+
113
+        if ($processId == '')
114
+        {
115
+            $processId = $a->process_id;
116
+        }
117
+
118
+        if (!is_string($msg)) {
119
+        	$msg = var_export($msg, true);
120
+        }
121
+
122
+        $callers = debug_backtrace();
123
+        $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n",
124
+                DateTimeFormat::utcNow(),
125
+                $processId,
126
+                basename($callers[0]['file']),
127
+                $callers[0]['line'],
128
+                $callers[1]['function'],
129
+                $msg
130
+            );
315 131
 
316 132
         $stamp1 = microtime(true);
317
-        self::$devLogger->log($level, $msg);
318
-        self::getApp()->saveTimestamp($stamp1, "file");
133
+        @file_put_contents($logfile, $logline, FILE_APPEND);
134
+        $a->saveTimestamp($stamp1, "file");
319 135
     }
320 136
 }

+ 0
- 50
src/Util/Logger/FriendicaDevelopHandler.php View File

@@ -1,50 +0,0 @@
1
-<?php
2
-
3
-namespace Friendica\Util\Logger;
4
-
5
-use Monolog\Handler;
6
-use Monolog\Logger;
7
-
8
-/**
9
- * Simple handler for Friendica developers to use for deeper logging
10
- *
11
- * If you want to debug only interactions from your IP or the IP of a remote server for federation debug,
12
- * you'll use Logger::develop() for the duration of your work, and you clean it up when you're done before submitting your PR.
13
- */
14
-class FriendicaDevelopHandler extends Handler\AbstractHandler
15
-{
16
-	/**
17
-	 * @var string The IP of the developer who wants to debug
18
-	 */
19
-	private $developerIp;
20
-
21
-	/**
22
-	 * @param string $developerIp  The IP of the developer who wants to debug
23
-	 * @param int    $level        The minimum logging level at which this handler will be triggered
24
-	 * @param bool   $bubble       Whether the messages that are handled can bubble up the stack or not
25
-	 */
26
-	public function __construct($developerIp, $level = Logger::DEBUG, $bubble = true)
27
-	{
28
-		parent::__construct($level, $bubble);
29
-
30
-		$this->developerIp = $developerIp;
31
-	}
32
-
33
-	/**
34
-	 * {@inheritdoc}
35
-	 */
36
-	public function handle(array $record)
37
-	{
38
-		if (!$this->isHandling($record)) {
39
-			return false;
40
-		}
41
-
42
-		/// Just in case the remote IP is the same as the developer IP log the output
43
-		if (!is_null($this->developerIp) && $_SERVER['REMOTE_ADDR'] != $this->developerIp)
44
-		{
45
-			return false;
46
-		}
47
-
48
-		return false === $this->bubble;
49
-	}
50
-}

+ 0
- 116
src/Util/LoggerFactory.php View File

@@ -1,116 +0,0 @@
1
-<?php
2
-
3
-namespace Friendica\Util;
4
-
5
-use Friendica\Network\HTTPException\InternalServerErrorException;
6
-use Friendica\Util\Logger\FriendicaDevelopHandler;
7
-use Monolog;
8
-use Psr\Log\LoggerInterface;
9
-use Psr\Log\LogLevel;
10
-
11
-/**
12
- * A logger factory
13
- *
14
- * Currently only Monolog is supported
15
- */
16
-class LoggerFactory
17
-{
18
-	/**
19
-	 * Creates a new PSR-3 compliant logger instances
20
-	 *
21
-	 * @param string $channel The channel of the logger instance
22
-	 *
23
-	 * @return LoggerInterface The PSR-3 compliant logger instance
24
-	 */
25
-	public static function create($channel)
26
-	{
27
-		$logger = new Monolog\Logger($channel);
28
-		$logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor());
29
-		$logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor());
30
-
31
-		// Add more information in case of a warning and more
32
-		$logger->pushProcessor(new Monolog\Processor\IntrospectionProcessor(LogLevel::WARNING, [], 1));
33
-
34
-		return $logger;
35
-	}
36
-
37
-	/**
38
-	 * Creates a new PSR-3 compliant develop logger
39
-	 *
40
-	 * If you want to debug only interactions from your IP or the IP of a remote server for federation debug,
41
-	 * you'll use this logger instance for the duration of your work.
42
-	 *
43
-	 * It should never get filled during normal usage of Friendica
44
-	 *
45
-	 * @param string $channel      The channel of the logger instance
46
-	 * @param string $developerIp  The IP of the developer who wants to use the logger
47
-	 *
48
-	 * @return LoggerInterface The PSR-3 compliant logger instance
49
-	 */
50
-	public static function createDev($channel, $developerIp)
51
-	{
52
-		$logger = new Monolog\Logger($channel);
53
-		$logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor());
54
-		$logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor());
55
-
56
-		$logger->pushProcessor(new Monolog\Processor\IntrospectionProcessor(Loglevel::DEBUG, [], 1));
57
-
58
-		$logger->pushHandler(new FriendicaDevelopHandler($developerIp));
59
-
60
-		return $logger;
61
-	}
62
-
63
-	/**
64
-	 * Adding a handler to a given logger instance
65
-	 *
66
-	 * @param LoggerInterface $logger  The logger instance
67
-	 * @param mixed           $stream  The stream which handles the logger output
68
-	 * @param string          $level   The level, for which this handler at least should handle logging
69
-	 *
70
-	 * @return void
71
-	 *
72
-	 * @throws InternalServerErrorException if the logger is incompatible to the logger factory
73
-	 * @throws \Exception in case of general failures
74
-	 */
75
-	public static function addStreamHandler($logger, $stream, $level = LogLevel::NOTICE)
76
-	{
77
-		if ($logger instanceof Monolog\Logger) {
78
-			$fileHandler = new Monolog\Handler\StreamHandler($stream, Monolog\Logger::toMonologLevel($level));
79
-
80
-			$formatter = new Monolog\Formatter\LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
81
-			$fileHandler->setFormatter($formatter);
82
-
83
-			$logger->pushHandler($fileHandler);
84
-		} else {
85
-			throw new InternalServerErrorException('Logger instance incompatible for MonologFactory');
86
-		}
87
-	}
88
-
89
-	/**
90
-	 * This method enables the test mode of a given logger
91
-	 *
92
-	 * @param LoggerInterface $logger The logger
93
-	 *
94
-	 * @return Monolog\Handler\TestHandler the Handling for tests
95
-	 *
96
-	 * @throws InternalServerErrorException if the logger is incompatible to the logger factory
97
-	 */
98
-	public static function enableTest($logger)
99
-	{
100
-		if ($logger instanceof Monolog\Logger) {
101
-			// disable every handler so far
102
-			$logger->pushHandler(new Monolog\Handler\NullHandler());
103
-
104
-			// enable the test handler
105
-			$fileHandler = new Monolog\Handler\TestHandler();
106
-			$formatter = new Monolog\Formatter\LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
107
-			$fileHandler->setFormatter($formatter);
108
-
109
-			$logger->pushHandler($fileHandler);
110
-
111
-			return $fileHandler;
112
-		} else {
113
-			throw new InternalServerErrorException('Logger instance incompatible for MonologFactory');
114
-		}
115
-	}
116
-}

+ 0
- 8
tests/include/ApiTest.php View File

@@ -11,8 +11,6 @@ use Friendica\Core\PConfig;
11 11
 use Friendica\Core\Protocol;
12 12
 use Friendica\Core\System;
13 13
 use Friendica\Network\HTTPException;
14
-use Friendica\Util\LoggerFactory;
15
-use Monolog\Handler\TestHandler;
16 14
 
17 15
 require_once __DIR__ . '/../../include/api.php';
18 16
 
@@ -24,11 +22,6 @@ require_once __DIR__ . '/../../include/api.php';
24 22
  */
25 23
 class ApiTest extends DatabaseTest
26 24
 {
27
-	/**
28
-	 * @var TestHandler Can handle log-outputs
29
-	 */
30
-	protected $logOutput;
31
-
32 25
 	/**
33 26
 	 * Create variables used by tests.
34 27
 	 */
@@ -37,7 +30,6 @@ class ApiTest extends DatabaseTest
37 30
 		parent::setUp();
38 31
 
39 32
 		$this->app = BaseObject::getApp();
40
-		$this->logOutput = LoggerFactory::enableTest($this->app->getLogger());
41 33
 
42 34
 		// User data that the test database is populated with
43 35
 		$this->selfUser = [

+ 1
- 4
tests/src/BaseObjectTest.php View File

@@ -7,7 +7,6 @@ namespace Friendica\Test;
7 7
 
8 8
 use Friendica\App;
9 9
 use Friendica\BaseObject;
10
-use Friendica\Util\LoggerFactory;
11 10
 use PHPUnit\Framework\TestCase;
12 11
 
13 12
 /**
@@ -39,9 +38,7 @@ class BaseObjectTest extends TestCase
39 38
 	 */
40 39
 	public function testSetApp()
41 40
 	{
42
-		$logger = $logger = LoggerFactory::create('test');
43
-		$app = new App(__DIR__ . '/../../', $logger);
44
-		LoggerFactory::enableTest($logger);
41
+		$app = new App(__DIR__ . '/../../');
45 42
 		$this->assertNull($this->baseObject->setApp($app));
46 43
 		$this->assertEquals($app, $this->baseObject->getApp());
47 44
 	}

+ 3
- 3
update.php View File

@@ -332,8 +332,8 @@ function update_1298()
332 332
 					$fail++;
333 333
 				} else {
334 334
 					DBA::update('profile', [$translateKey => $key], ['id' => $data['id']]);
335
-					Logger::notice('Updated contact', ['action' => 'update', 'contact' => $data['id'], "$translateKey" => $key,
336
-						'was' => $data[$translateKey]]);
335
+					logger::log('Updated contact ' . $data['id'] . " to $translateKey " . $key .
336
+						' (was: ' . $data[$translateKey] . ')');
337 337
 					Worker::add(PRIORITY_LOW, 'ProfileUpdate', $data['id']);		
338 338
 					Contact::updateSelfFromUserID($data['id']);
339 339
 					GContact::updateForUser($data['id']);
@@ -342,7 +342,7 @@ function update_1298()
342 342
 			}
343 343
 		}
344 344
 
345
-		Logger::notice($translateKey . " fix completed", ['action' => 'update', 'translateKey' => $translateKey, 'Success' => $success, 'Fail' => $fail ]);
345
+		Logger::log($translateKey . " fix completed. Success: $success. Fail: $fail");	
346 346
 	}
347 347
 	return Update::SUCCESS;
348 348
 }

Loading…
Cancel
Save