@@ -8,6 +8,7 @@ It takes care of
88- ** help page generation**
99- ** automatic width adjustment**
1010- ** colored output**
11+ - ** optional PSR3 compatibility**
1112
1213It is lightweight and has ** no 3rd party dependencies** .
1314
@@ -83,18 +84,20 @@ passing false to the constructor.
8384You can use the provided `` splitbrain\phpcli\Exception `` to signal any problems within your main code yourself. The
8485exceptions's code will be used as the exit code then.
8586
87+ Stacktraces will be printed on log level ` debug ` .
88+
8689## Colored output
8790
8891Colored output is handled through the `` Colors `` class. It tries to detect if a color terminal is available and only
8992then uses terminal colors. You can always suppress colored output by passing `` --no-colors `` to your scripts.
93+ Disabling colors will also disable the emoticon prefixes.
9094
9195Simple colored log messages can be printed by you using the convinence methods `` success() `` (green), `` info() `` (cyan),
9296`` error() `` (red) or `` fatal() `` (red). The latter will also exit the programm with a non-zero exit code.
9397
9498For more complex coloring you can access the color class through `` $this->colors `` in your script. The `` wrap() `` method
9599is probably what you want to use.
96100
97-
98101The table formatter allows coloring full columns. To use that mechanism pass an array of colors as third parameter to
99102its `` format() `` method. Please note that you can not pass colored texts in the second parameters (text length calculation
100103and wrapping will fail, breaking your texts).
@@ -123,3 +126,33 @@ Space for borders is automatically calculated. It is recommended to always have
123126column to adjust for different terminal widths.
124127
125128The table formatter is used for the automatic help screen accessible when calling your script with `` -h `` or `` --help `` .
129+
130+ ## PSR-3 Logging
131+
132+ The CLI class is a fully PSR-3 compatible logger (printing colored log data to STDOUT and STDERR). This is useful when
133+ you call backend code from your CLI that expects a Logger instance to produce any sensible status output while running.
134+
135+ To use this ability simply inherit from ` splitbrain\phpcli\PSR3CLI ` instead of ` splitbrain\phpcli\CLI ` , then pass ` $this `
136+ as the logger instance. Be sure you have the suggested ` psr/log ` composer package installed.
137+
138+ ![ Screenshot] ( screenshot2.png )
139+
140+ You can adjust the verbosity of your CLI tool using the ` --loglevel ` parameter. Supported loglevels are the PSR-3
141+ loglevels and our own ` success ` level:
142+
143+ * debug
144+ * info
145+ * notice
146+ * success
147+ * warning
148+ * error
149+ * critical
150+ * alert
151+ * emergency
152+
153+ Convenience methods for all log levels are available. Placeholder interpolation as described in PSR-3 is available, too.
154+ Messages from ` warning ` level onwards are printed to ` STDERR ` all below are printed to ` STDOUT ` .
155+
156+ The default log level of your script can be set by overwriting the ` $logdefault ` member.
157+
158+ See ` example/logging.php ` for an example.
0 commit comments