Skip to content

Commit 370033d

Browse files
Merge pull request #14 from codenamephp/feature/13-add-logging-functions
Added logging function
2 parents 975595f + d1a5752 commit 370033d

6 files changed

Lines changed: 124 additions & 3 deletions

File tree

MIGRATION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ If you use the All class you don't need to do anything.
1212
The iAll interface was extended with the iWithin interface. If you created your own implementation of iAll you need to implement the iWithin interface as well.
1313
If you use the All class you don't need to do anything.
1414

15+
### Info Method
16+
The iAll interface was extended with the iInfo interface. If you created your own implementation of iAll you need to implement the iInfo interface as well.
17+
If you use the All class you don't need to do anything.
18+
19+
### Warning Method
20+
The iAll interface was extended with the iWarning interface. If you created your own implementation of iAll you need to implement the iWarning interface as well.
21+
If you use the All class you don't need to do anything.
22+
23+
### Writeln Method
24+
The iAll interface was extended with the iWriteln interface. If you created your own implementation of iAll you need to implement the iWriteln interface as well.
25+
If you use the All class you don't need to do anything.
26+
1527
## 1.x -> 2.x
1628

1729
The ssh connection string is now part of `\Deployer\Host\Host`. This means the

src/functions/All.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use function Deployer\currentHost;
3535
use function Deployer\download;
3636
use function Deployer\get;
37+
use function Deployer\info;
3738
use function Deployer\input;
3839
use function Deployer\on;
3940
use function Deployer\option;
@@ -42,7 +43,9 @@
4243
use function Deployer\runLocally;
4344
use function Deployer\set;
4445
use function Deployer\upload;
46+
use function Deployer\warning;
4547
use function Deployer\within;
48+
use function Deployer\writeln;
4649

4750
/**
4851
* Implements all method interfaces so we a "all drop-in" class to easily access the methods
@@ -171,7 +174,19 @@ public function upload(string $source, string $destination, array $config = [])
171174
upload($source, $destination, $config);
172175
}
173176

177+
public function warning(string $message) : void {
178+
warning($message);
179+
}
180+
174181
public function within(string $path, callable $callback) : mixed {
175182
return within($path, $callback);
176183
}
184+
185+
public function info(string $message) : void {
186+
info($message);
187+
}
188+
189+
public function writeln(string $message) : void {
190+
writeln($message);
191+
}
177192
}

src/functions/iAll.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@
2222
*
2323
* The idea is to provide a stable, typed API and also a level of abstraction to the global deployer functions so testing is easier.
2424
*/
25-
interface iAll extends iAdd, iAfter, iBefore, iCurrentHost, iDownload, iGet, iHost, iInput, iLocalhost, iOn, iParse, iRun, iSet, iTask, iUpload, iWithin {
26-
27-
}
25+
interface iAll extends iAdd, iAfter, iBefore, iCurrentHost, iDownload, iGet, iHost, iInfo, iInput, iLocalhost, iOn, iParse, iRun, iSet, iTask, iUpload, iWarning, iWithin, iWriteln {}

src/functions/iInfo.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2023 Bastian Schwarz <[email protected]>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\base\functions;
19+
20+
/**
21+
* Interface for the Deployer\info function
22+
*/
23+
interface iInfo {
24+
25+
/**
26+
* Writes an info message to the output
27+
*
28+
* @param string $message The message to write
29+
* @return void
30+
*/
31+
public function info(string $message) : void;
32+
}

src/functions/iWarning.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2023 Bastian Schwarz <[email protected]>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\base\functions;
19+
20+
/**
21+
* Interface for the Deployer\warning function
22+
*/
23+
interface iWarning {
24+
25+
/**
26+
* Writes a warning message to the console
27+
*
28+
* @param string $message The message to write
29+
* @return void
30+
*/
31+
public function warning(string $message) : void;
32+
}

src/functions/iWriteln.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* Copyright 2023 Bastian Schwarz <[email protected]>.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace de\codenamephp\deployer\base\functions;
19+
20+
/**
21+
* Interface for the Deployer\writeln function
22+
*/
23+
interface iWriteln {
24+
25+
/**
26+
* Writes a message to the console and adds a newline at the end
27+
*
28+
* @param string $message The message to write
29+
* @return void
30+
*/
31+
public function writeln(string $message) : void;
32+
}

0 commit comments

Comments
 (0)