- Notifications
You must be signed in to change notification settings - Fork 29
merge for 1.0 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
merge for 1.0 #20
Changes from 1 commit
Commits
Show all changes
34 commits Select commit Hold shift + click to select a range
08582e2 Improved logging, enumerations and more
kleisauke 593c24a Merge pull request #15 from kleisauke/logging-enumerations
jcupitt ef0d885 pass PSR2, README updates
jcupitt a1e2e6e remove Enum from enum names, version bump
jcupitt d1727aa Override __toString() + remove enums import
kleisauke cc2a01d add notes on scope to the README
jcupitt 22d2277 add formatted docs to repro
jcupitt d582081 make tests run in less RAM
jcupitt 02d3c39 better write to file exception test
jcupitt d91b499 add sig.php example
jcupitt ff4e79f move logger
jcupitt 95888ac all seems to work
jcupitt e9bee8f fix sig.php
jcupitt efd538f fix some phpcs warnings
jcupitt 706072b make a separate Logger class
jcupitt 1b44116 move debug/error logging convenience into Main
jcupitt d0efc5f fix Logger image->string conversion
jcupitt a1ad5e3 Merge branch 'add-default-logger' of github.com:jcupitt/php-vips into…
jcupitt cb42841 remove @version tags
jcupitt eeb8483 update docs
jcupitt f4d4fb5 avoid AND/OR member names
jcupitt 6e99cdd regen docs, again
jcupitt 44c805e incorporate review comments
jcupitt e6bd0e5 Merge branch 'dev' into add-default-logger
jcupitt 2e5cc1b ready to merge to dev
jcupitt c3ac43d rename error() and debug()
jcupitt d63c9da remove :void return
jcupitt 420b9f4 regen docs
jcupitt e79da93 update docs without cache files
jcupitt c00f6af remove left-over debugLog() etc.
jcupitt 2d7fb28 update docs
jcupitt d80e827 remove formatted docs, bump to 1.0.0
jcupitt e0c521b fixes for review comments
jcupitt 7fd21be revise README for 1.0
jcupitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
make a separate Logger class
and move the logging interface into Main
- Loading branch information
commit 706072b580b19b1b4e84bc8e2b6d0c3e31fcb093
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| <?php | ||
| | ||
| /** | ||
| * Vips is a php binding for the vips image processing library | ||
| * | ||
| * PHP version 7 | ||
| * | ||
| * LICENSE: | ||
| * | ||
| * Copyright (c) 2016 John Cupitt | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining | ||
| * a copy of this software and associated documentation files (the | ||
| * "Software"), to deal in the Software without restriction, including | ||
| * without limitation the rights to use, copy, modify, merge, publish, | ||
| * distribute, sublicense, and/or sell copies of the Software, and to | ||
| * permit persons to whom the Software is furnished to do so, subject to | ||
| * the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be | ||
| * included in all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
| * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
| * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
| * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| * | ||
| * @category Images | ||
| * @package Jcupitt\Vips | ||
| * @author John Cupitt <jcupitt@gmail.com> | ||
| * @copyright 2016 John Cupitt | ||
| * @license https://opensource.org/licenses/MIT MIT | ||
| * @version GIT:ad44dfdd31056a41cbf217244ce62e7a702e0282 | ||
| * @link https://github.com/jcupitt/php-vips | ||
| */ | ||
| | ||
| namespace Jcupitt\Vips; | ||
| | ||
| use \Psr\Log\LoggerInterface; | ||
| | ||
| const LOG_FORMAT = "[%datetime%] %level_name%: %message% %context%\n"; | ||
| const DATE_FORMAT = "Y-m-d\TH:i:sP"; | ||
| | ||
| /** | ||
| * A simple logger, handy for debugging. See Main::setLogger(). | ||
| * | ||
| * @category Images | ||
| * @package Jcupitt\Vips | ||
| * @author John Cupitt <jcupitt@gmail.com> | ||
| * @copyright 2016 John Cupitt | ||
| * @license https://opensource.org/licenses/MIT MIT | ||
| * @version Release:0.9.0 | ||
| * @link https://github.com/jcupitt/php-vips | ||
| */ | ||
| class Logger implements LoggerInterface | ||
| { | ||
| // Use the LoggerTrait so that we only have to implement the generic | ||
| // log method. | ||
| use \Psr\Log\LoggerTrait; | ||
| | ||
| /** | ||
| * Logs with an arbitrary level. | ||
| * | ||
| * @param mixed $level | ||
| * @param string $message | ||
| * @param array $context | ||
| * | ||
| * @return void | ||
| */ | ||
| public function log($level, $message, array $context = []) | ||
| { | ||
| // `Vips\Image` to string convert | ||
| array_walk_recursive($context, function (&$value) { | ||
| if ($value instanceof Vips\Image) { | ||
| $value = (string) $value; | ||
| } | ||
| }); | ||
| | ||
| $strParams = [ | ||
| '%datetime%' => date(DATE_FORMAT), | ||
| '%level_name%' => $level, | ||
| '%message%' => $message, | ||
| '%context%' => json_encode( | ||
| $context, | ||
| JSON_UNESCAPED_SLASHES | | ||
| JSON_UNESCAPED_UNICODE | | ||
| JSON_PRESERVE_ZERO_FRACTION | ||
| ), | ||
| ]; | ||
| | ||
| echo strtr(LOG_FORMAT, $strParams); | ||
| } | ||
| } | ||
| | ||
| /* | ||
| * Local variables: | ||
| * tab-width: 4 | ||
| * c-basic-offset: 4 | ||
| * End: | ||
| * vim600: expandtab sw=4 ts=4 fdm=marker | ||
| * vim<600: expandtab sw=4 ts=4 | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoggerInterfaceis no longer used in this class, so this can be removed.