| Logging Everything of make process |
| |
| The console's scrollback buffer will often prove to be too small to keep the full output of the package build process. |
| |
| There are moments you want to enable logging of the build process so that you can comfortably search(grep) through the logfiles |
| when there appears to be a problem with building process |
| |
| The command looks like this: |
| |
| make -j2 V=99 2>&1 | tee build.log |
| |
| 0 is stdin. 1 is stdout. 2 is stderr |
| |
| There's one way to remember this construct (maybe it is not entirely accurate): |
| ------------- |
| First of all, 2>1 looks like a very good way to redirect stderr to stdout. but remember, |
| it has a very harmful disadvantage: it may actually be interpreted as "redirect stderr to a file named 1". |
| ------------- |
| & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1. |
| ------------- |
| >& is shell syntax for "fold a file descriptor into another", you can also interprete it as |
| "it is the syntax to redirect a stream to another file descriptor" |
| |
| The part " | tee build.log" causes a file build.log to be created (if it does not yet exist) and a copy of the text that |
| your script displays on the console is going to be written to it. |
| Any previous content of that logfile will be overwritten. |
| |
| The part "2>&1" means that you will also catch the ERROR output of failed commands. You would normally not notice, |
| but programs can write their output to "standard output" as well as "error output". |
| These are two separate "channels" if you like, and since the tee command will only catch "standard output" and |
| duplicate it into the target file, you will have to explicitly add "error output" as well. |
| Remember, the error output will often be the stuff you're most interested in! |
| |
| |
| By using this command, you are still able to watch the proceedings of the package build process on your console, |
| and afterwards you can open the log file in an editor at your leisure. |
| |
| look for the info: |
| |
| •Compilation errors ( grep -iE "(error|failed)" ) |
| •Header/include/library files missing ( grep -iE "(not found|unavailable)" ) |
| |
| ref: http://tldp.org/LDP/abs/html/io-redirection.html |
| |