Welcome to mklog’s documentation!

mklog is a python program that converts standard input, content of files, or output of a command in a log-like format, i.e. current date and time is prepended to each line.

Download and install

See the main project page for instructions, and changelog.

Usage

Here are the command line options for mklog.

Print the standard input, content of files, or result of a command to standard output, preceded by date and time (in a log-like way).

usage: mklog [-h] [--version] [-f LINE_FORMAT] [-t TIME_FORMAT] [-c ...]
             [FILES ...]

Positional Arguments

FILES

Files to process.

Named Arguments

--version

show program’s version number and exit

-f, --format

Format of output. Interpreted sequences are “{time}” for current time, “{line}” for lines of the command. Default is “{time} {line}”.

Default: “{time} {line}”

-t, --time-format

Format of time. See the “time” documentation for more information about format (e.g. http://docs.python.org/library/time.html#time.strftime). Default is “%Y-%m-%d %H:%M:%S”.

Default: “%Y-%m-%d %H:%M:%S”

-c, --command

Run command, processing both its standard and error output.

Commands can be written whithout quotes (such as mklog -c tail -f file1 file2), or with it, which allows using shell features (such as mklog -c “(ls; cat file1) & cat file2”).

Destination of output is preserved: standard output of command is written to standard output of mklog, and standard error to standard error. Both are processed.

This must be the last option on the command line.

mklog aims to be a simple way to write text in a log format, i.e. each line being preceded by date and time it was written. Text can be either standard input, content of files, or both standard and error output of a command.

If neither files nor a command are given, standard input is processed. Otherwise, the content of each file (if any), and the output of the command (if any) are processed.

# Environment

When executing command (with -c option), environment is preserved, and command should run exactly the same way it should have run if it had been executed directly within the shell.

Indices and tables