mirror of
https://github.com/varunsridharan/actions-toolkit.git
synced 2024-09-20 15:06:10 +08:00
Updated PHP
This commit is contained in:
parent
93bb3790ac
commit
639ad3a018
50
README.md
50
README.md
|
@ -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.
|
||||
|
||||
|
|
35
test/php.php
35
test/php.php
|
@ -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' );
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/php/logger.php';
|
||||
require_once __DIR__ . '/php/logger.php';
|
||||
require_once __DIR__ . '/php/log-functions.php';
|
33
toolkit/php/log-functions.php
Normal file
33
toolkit/php/log-functions.php
Normal 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";
|
||||
}
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue