Skip to content

Commit 6b96efc

Browse files
authored
Add stdout/stderr outputs to FAQ (#4175)
* Add stdout/stderr to faq * Crosslink
1 parent c19891e commit 6b96efc

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

knowledge/faq.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,40 @@ The general best practices are:
222222
- Keep the versions aligned. If using a version range try to use the same version range everywhere.
223223
- Declare first dependencies that use fixed version, not version ranges
224224
- Use the ``conan graph info ... --format=html > graph.html`` graphical interactive output to understand and navigate conflicts.
225+
226+
.. _faq_stdout_stderr_redirects:
227+
228+
Conan is redirecting its output to stderr
229+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230+
231+
As explained :ref:`in the commands reference<commands_output>`,
232+
by design Conan redirects its logging information to the standard error output (stderr),
233+
while the actual results of the commands are sent to the standard output (stdout).
234+
235+
This is done to allow users to easily redirect the output of Conan commands to files or other
236+
processes without having the logging information mixed with the actual results.
237+
238+
For example, running a command like:
239+
240+
.. code-block:: text
241+
242+
$ conan graph info --requires=zlib/1.3.1 --format=json > graph.json
243+
244+
...
245+
246+
======== Computing dependency graph ========
247+
Graph root
248+
cli
249+
Requirements
250+
zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76 - Cache
251+
252+
======== Computing necessary packages ========
253+
Connecting to remote 'conancenter' anonymously
254+
Requirements
255+
zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76:dbb40f41e6e9a5c4a9a1fd8d9e6ccf6d92676c92#8976086f07d37e3f6288e2fccf9650ae - Cache
256+
257+
will create a file named ``graph.json`` with the JSON output of the command, but it will not
258+
include any logging information, which will be printed to the console.
259+
260+
Note that this approach is common in many command-line tools such as ``git`` and ``curl``,
261+
and it is not specific to Conan.

reference/commands.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ common practices in many CLI tools and the `POSIX standard
101101
- ``stderr``: For diagnostic output, including logs, warnings, errors, and progress
102102
messages.
103103

104+
More info can be found more in the :ref:`FAQ section<faq_stdout_stderr_redirects>`.
105+
104106
**Redirecting Output to Files**
105107

106108
You can redirect Conan output to files using shell redirection:

0 commit comments

Comments
 (0)