Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/lookup-server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2022-09-05 16:49:20 +0300
committerMaxence Lange <maxence@artificial-owl.com>2022-09-05 16:49:20 +0300
commit97ab18dbe942f4e38365eb8fda48023134981bea (patch)
treee8b4abafe535b7a725dc6bb7659dc712e41651d7
parent95aaf59c941018e27a4fed2fef7689ea9b97c508 (diff)
quick implementation of some logginenh/noid/quick-debug-feat
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--.gitignore1
-rw-r--r--server/.htaccess5
-rw-r--r--server/index.php6
-rw-r--r--server/init.php6
-rw-r--r--server/lib/Tools/Traits/TDebug.php13
5 files changed, 17 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 1f05715..6b03733 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.idea/
server/vendor/
+build/
diff --git a/server/.htaccess b/server/.htaccess
index 51c6bee..d089512 100644
--- a/server/.htaccess
+++ b/server/.htaccess
@@ -1,3 +1,8 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
+
+<Files "debug.log">
+ Order Allow,Deny
+ Deny from all
+</Files>
diff --git a/server/index.php b/server/index.php
index 52c3284..7a1baaa 100644
--- a/server/index.php
+++ b/server/index.php
@@ -42,6 +42,12 @@ if (!isset($app) || !isset($container)) {
return;
}
+function debug(string $line) {
+ if (defined('_DEBUG_')) {
+ file_put_contents(__DIR__ . '/debug.log', '. ' . $line . "\n", FILE_APPEND);
+ }
+}
+
$r_search = function (ServerRequestInterface $request, ResponseInterface $response, array $args) {
/** @var UserManager $userManager */
$userManager = $this->get('UserManager');
diff --git a/server/init.php b/server/init.php
index 454513a..ff51e38 100644
--- a/server/init.php
+++ b/server/init.php
@@ -47,6 +47,11 @@ $app = AppFactory::create();
$app->setBasePath('');
$settings = require __DIR__ . '/src/config.php';
+$debug = $settings['settings']['debug'] ?? false;
+if (is_bool($debug) && $debug) {
+ define('_DEBUG_', true);
+}
+
$container->set('Settings', function (Container $c) use ($settings) {
return $settings;
});
@@ -55,4 +60,3 @@ $container->set('DependenciesService', function (Container $c) {
return new DependenciesService($c->get('Settings'));
});
$container->get('DependenciesService')->initContainer($container, $app);
-
diff --git a/server/lib/Tools/Traits/TDebug.php b/server/lib/Tools/Traits/TDebug.php
deleted file mode 100644
index 73c9d12..0000000
--- a/server/lib/Tools/Traits/TDebug.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace LookupServer\Tools\Traits;
-
-
-trait TDebug {
-
- public function debug(string $line) {
- // this is ugly, but at least we have some debug somewhere
- @file_put_contents(__DIR__ . '/../../debug.log', $line . "\n", FILE_APPEND);
- }
-
-}