Updated PHP

This commit is contained in:
Varun 2020-10-21 10:56:08 +05:30
parent 93bb3790ac
commit 639ad3a018
No known key found for this signature in database
GPG key ID: 93FB46DCF16E0D6F
5 changed files with 113 additions and 10 deletions

View file

@ -136,6 +136,56 @@ gh_validate_input "CUSTOM_INPUT_NAM2" "Sorry Can't Process The Request. CUSTOM_E
---
### PHP Script
#### `gh_log`
```php
# Logs The Given Value
gh_log("Sample Log In Github Actions");
```
### `gh_log_group_*`
```php
gh_log_group_start( "Group Name" );
gh_log( "Log Line 1" );
gh_log( "Log Line 2" );
gh_log( "Log Line 3" );
gh_log_group_end();
```
#### `GH_LOG::*` && `gh_log_*`
```php
# Github Action Warning Log
gh_log_yellow( 'This Will Be Displayed As Warning In Github Actions Log' );
# Github Action Warning Log With Emoji
gh_log_warning( 'This Will Be Displayed With A Warning Emoji' );
# Github Action Error Log
gh_log_red( 'This Will Be Displayed As Error In Github Actions Log' );
# Github Action Error Log With Emoji
gh_log_error( 'This Will Be Displayed With A Error Emoji' );
# Github Actions Debug Log
gh_log_debug( 'This Will Be Displayed As Debug Log in Github Actions Log If Debug Enabled' );
// ::log method usage
// -------------------------------------------------------
GH_LOG::log( 'Im Red!', 'red' );
GH_LOG::log( 'Im Blue on White!', 'white', true, 'blue' );
GH_LOG::log( 'I dont have an EOF', false );
GH_LOG::log( "\tThis is where I come in.", 'light_green' );
GH_LOG::log( 'You can swap my variables', 'black', 'yellow' );
GH_LOG::log( str_repeat( '-', 60 ) );
GH_LOG::blue( 'Blue Text' );
GH_LOG::black( 'Black Text on Magenta Background', 'magenta' );
GH_LOG::red( 'Im supposed to be red, but Im reversed!', 'reverse' );
GH_LOG::red( 'I have an underline', 'underline' );
GH_LOG::blue( 'I should be blue on light gray but Im reversed too.', 'light_gray', 'reverse' );
```
## 📝 Changelog
All notable changes to this project will be documented in this file.

View file

@ -1,20 +1,39 @@
<?php
include_once '/gh-toolkit/php.php';
gh_log( 'Sample Log In Github Actions' );
gh_log_group_start( 'Group Name' );
gh_log( 'Log Line 1' );
gh_log( 'Log Line 2' );
gh_log( 'Log Line 3' );
gh_log_group_end();
# Github Action Warning Log
gh_log_yellow( 'This Will Be Displayed As Warning In Github Actions Log' );
# Github Action Warning Log With Emoji
gh_log_warning( 'This Will Be Displayed With A Warning Emoji' );
# Github Action Error Log
gh_log_red( 'This Will Be Displayed As Error In Github Actions Log' );
# Github Action Error Log With Emoji
gh_log_error( 'This Will Be Displayed With A Error Emoji' );
# Github Actions Debug Log
gh_log_debug( 'This Will Be Displayed As Debug Log in Github Actions Log If Debug Enabled' );
// ::log method usage
// -------------------------------------------------------
GH_LOG::log( 'Im Red!', 'red' );
GH_LOG::log( 'Im Blue on White!', 'white', true, 'blue' );
GH_LOG::log( 'I dont have an EOF', false );
GH_LOG::log( "\tThis is where I come in.", 'light_green' );
GH_LOG::log( 'You can swap my variables', 'black', 'yellow' );
GH_LOG::log( str_repeat( '-', 60 ) );
// Direct usage
// -------------------------------------------------------
echo GH_LOG::blue( 'Blue Text' ) . "\n";
echo GH_LOG::black( 'Black Text on Magenta Background', 'magenta' ) . "\n";
echo GH_LOG::red( 'Im supposed to be red, but Im reversed!', 'reverse' ) . "\n";
echo GH_LOG::red( 'I have an underline', 'underline' ) . "\n";
echo GH_LOG::blue( 'I should be blue on light gray but Im reversed too.', 'light_gray', 'reverse' ) . "\n";
GH_LOG::blue( 'Blue Text' );
GH_LOG::black( 'Black Text on Magenta Background', 'magenta' );
GH_LOG::red( 'Im supposed to be red, but Im reversed!', 'reverse' );
GH_LOG::red( 'I have an underline', 'underline' );
GH_LOG::blue( 'I should be blue on light gray but Im reversed too.', 'light_gray', 'reverse' );

View file

@ -1,3 +1,4 @@
<?php
require_once __DIR__ . '/php/logger.php';
require_once __DIR__ . '/php/log-functions.php';

View file

@ -0,0 +1,33 @@
<?php
function gh_log( $content ) {
echo $content;
}
function gh_log_group_start( $content ) {
echo "###[group]$content";
}
function gh_log_group_end() {
echo '###[endgroup]';
}
function gh_log_yellow( $content ) {
echo "###[warning]$content";
}
function gh_log_warning( $content ) {
gh_log_yellow( "⚠️ $content" );
}
function gh_log_red( $content ) {
echo "###[error]$content";
}
function gh_log_error( $content ) {
gh_log_red( "🛑️ $content" );
}
function gh_log_debug( $content ) {
echo "::debug::$content";
}

View file

@ -72,7 +72,7 @@ class GH_LOG {
$newline = true;
}
$str = $newline ? $str . self::$eof : $str;
echo self::$color( $str, $background_color );
gh_log( self::$color( $str, $background_color ) );
}
/**