Commit Graph

62 Commits

Author SHA1 Message Date
c66af4648c Move thread-related classes from pocketmine to pocketmine\thread namespace 2019-06-18 17:36:25 +01:00
714393820f MainLogger: Use millisecond precision on log timestamps 2019-06-10 19:14:08 +01:00
1fd4077907 MainLogger: Always use CRITICAL for logException() 2019-03-29 15:28:11 +00:00
6c8fa8ae28 More nullable and void typehints 2019-03-02 10:29:11 +00:00
bbc8bc4df5 Move some error handling stuff to SPL 2019-01-17 19:16:03 +00:00
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
d86107e22a Terminal: Added write() and writeLine() to allow easily emitting Minecraft-formatted text to the console 2018-12-29 11:28:25 +00:00
498bffb34f Fixed --enable-ansi and --disable-ansi not being respected on threads
this causes some breakage to the behaviour of Terminal, and for that reason this is going on 4.0.

Terminal::hasFormattingCodes() will no longer auto-detect whether colour codes are supported.
2018-12-29 11:23:32 +00:00
34a899e28b Clean up Utils error handling functions (internal) 2018-12-16 17:50:00 +00:00
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
557fd34754 Make MainLogger independent of runtime-defined INI entries
Previously every thread using the logger had to inherit runtime-defined INI entries in order for the timezone to be set correctly. This removes that requirement.
2018-09-04 15:57:45 +01:00
d6d98183ea MainLogger: Log messages and exception traces in a synchronized block
this ensures that stack traces are emitted coherently without messages from other threads landing in the middle.
2018-08-03 18:50:06 +01:00
89643ff9af MainLogger: Added getFormat() and setFormat()
this allows plugins to easily alter the output of the console logger.
2018-06-10 10:49:12 +01:00
9657d50aeb MainLogger: workaround --disable-ansi not being respected on other threads 2018-06-10 10:24:49 +01:00
73e56c8a36 Utils: Make kill() use static MainLogger instead of global variable 2018-06-07 09:29:53 +01:00
889222e9c5 MainLogger: Use PTHREADS_INHERIT_NONE
this thread doesn't need to inherit anything because its sole purpose is to write log messages to file.
2018-05-12 12:39:13 +01:00
05f4262e81 MainLogger: moved format to private variable 2018-05-09 18:14:46 +01:00
b96adda14d MainLogger: Colorize at point of echo, not beforehand
this removes the need for a hack I had to do with ClientConsole to translate ANSI colour codes back into MC colour codes.
2018-05-09 18:04:16 +01:00
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
6a996611f8 Move functions from PocketMine.php to Utils
This cleans a lot of mess out of the bootstrap file, and also has the added bonus that threads which do not inherit functions can now get access to them by autoloading Utils.
2018-02-19 11:56:22 +00:00
b445825467 TextFormat: Moved toANSI() to Terminal, close #1995
This also removes a cyclic dependency between TextFormat and Terminal, meaning that TextFormat is now standalone without any external dependencies.

This is also an API break. Beware all ye who wander here, master = bleeding-edge!
2018-02-11 19:11:51 +00:00
d2d1df0447 MainLogger: Remove redundant condition
these are always ThreadedLoggerAttachments anyway, this code doesn't make sense.
2018-01-29 12:24:00 +00:00
f9b1afe4cf Fixed race condition causing exception log messages to sometimes not get written to disk when kill() is used
Synchronize with the logger thread when logging an exception or killing. This forces the main thread to wait for disk write to complete when logging exceptions or killing the process.
2018-01-29 12:04:23 +00:00
8aca373194 added some docs to shut PhpStorm up 2017-10-29 13:02:19 +00:00
7f5d8cc900 Always log stack traces regardless of whether log-debug is enabled 2017-09-09 19:27:26 +01:00
2215543e39 Fixed not being able to remove logger attachments, closes #1141 2017-09-05 20:04:19 +01:00
3fdbcee10f Add some typehints and documentation to MainLogger 2017-08-06 11:43:42 +01:00
4e9af1ac45 Fixed several extremely stupid bugs in MainLogger
- Fixed log writes being blocking (these were executed on a thread, but IN A SYNCHRONIZED BLOCK - what the fuck shoghi?!)
- Fixed log file being open for reading as well as writing
- The logger will now be buffered for 25ms before writing to disk, as it should have been to begin with.
- Moved the log resource to a local variable (it's unsafe to try to access resources from different threads, this takes away the ability to do so)
- Fixed line endings to use PHP_EOL instead of hardcoded LF, fix viewing logs in Notepadi
2017-08-06 10:56:39 +01:00
475066c9f5 Removed minor code duplication in MainLogger 2017-08-06 08:55:46 +01:00
dbb92096e4 More typehints, documentation fixes and static analysis cleanup 2017-07-15 12:12:06 +01:00
b5790d19bf Cleaned up MainLogger registration and declared a typehint
Remove null hint from MainLogger::getLogger() so static analysis doesn't complain everywhere
just make sure you register the logger before trying to use MainLogger::getLogger() on a different thread!
2017-07-14 11:39:04 +01:00
9c9095060f Register MainLogger on AsyncWorkers to make MainLogger::getLogger() usable in AsyncTasks
Threaded static properties aren't thread-local anymore in pthreads 3.1.7dev
2017-07-04 16:50:17 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
4c61ad9f2d Stop skipping stack frames (#425) 2017-03-19 10:24:33 +00:00
d6629d6843 More ?? (#131)
* More ??

* fix undefined variable
2016-11-30 10:07:37 +00:00
58ff381557 PhpStorm automated formatting (#11)
* PhpStorm reformatting

* Tuned PhpStorm reformatting

* Improved ItemIds and BlockIds formatting

* Tuned more PhpStorm reformatting

* Improved string concatenation
2016-10-03 19:05:48 +08:00
472fcfa4c7 Removed ThreadedFactory 2015-09-18 11:18:41 +02:00
e137ac4c56 Base PHP7 work to make it "run" - READ NEXT LINES!
All plugins will need to bump the API if they want to use this.
NOTE THAT THIS IS NOT THE FINAL API 2.0.0 AND THAT THERE WILL BE MORE CHANGES.
To start updating, you might also want to read https://secure.php.net/manual/en/migration70.php and specifically https://secure.php.net/manual/en/migration70.incompatible.php

To compile PHP7 with some of the required dependencies, use https://gist.github.com/shoghicp/166ab26ce5cc7a390f45
ONLY LINUX IS TESTED, DO NOT ASK FOR OTHER PLATFORMS!

----- THIS VERSION IS NOT SUPPORTED -----

This version WILL crash randomly in unexpected places due to PHP7, pthreads, PocketMine or cosmic rays.

Handle with care, and store under direct sunlight for the best performance.
2015-09-10 21:29:29 +02:00
7cf5df7e46 New console output formatting 2015-06-09 14:40:40 +02:00
f20d5b2c69 Fixed MainLogger 2015-05-29 11:38:18 +02:00
03f178379e Fixed items getting corrupted pickup delay, not being able to be killed by other damage sources 2015-05-28 22:17:12 +02:00
1666602652 Improved memory output, logging, removed locks 2015-03-22 03:20:48 +01:00
f9361aa931 Use new colors in terminal 2015-03-15 18:32:36 +01:00
b0f8c14640 Added Terminal class, Improved normal generator speed 2015-03-15 00:15:24 +01:00
5f4f996efe Fixed #2599 2015-02-15 19:01:25 +01:00
24c6cca664 Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() 2015-01-14 17:23:16 +01:00
3128ae9736 Improved exception handling and trace creation 2015-01-01 22:50:45 +01:00
2f6007342c Fixed server.log created in two different places on path changed 2014-12-22 23:00:28 +01:00