Log: Gwyddion Application Library Reference Manual

## Log Log — Logging data processing operations |

## Functions

void | gwy_log_add_full ()
void | gwy_log_add ()
void | gwy_log_add_import ()
void | gwy_log_add_synth ()
gboolean | gwy_log_get_enabled ()
void | gwy_log_set_enabled ()

## Includes

    #include <libgwyapp/gwyapp.h>

## Description

The data processing operation log is a linear sequence of operations applied to a image, volume, XYZ or curve map data. The log is informative and not meant to capture all information necessary to reply the operations, even though it can be sufficient for this purpose in simple cases.

The log is a linear sequence. This is only an approximation of the actual flow of information in the data processing, which corresponds to an acyclic directed graph (not necessarily connected as data, masks and presentations can have distinct sources). The following rules thus apply to make it meaningful and useful.

Each logging function takes two data identifiers: source and target. The source corresponds to the operation input, the target corresponds to the data whose log is being updated. The target may have already a log only if it is the same as the source (which corresponds to simple data modification such as levelling or grain marking). In all other cases the target must not have a log yet – they represent the creation of new data either from scratch or based on existing data (in the latter case the log of the existing data is replicated to the new one).

Complex multi-data operations are approximated by one of the simple operations. For instance, data arithmetic can be treated as the construction of a new channel from scratch as it is unclear which input data the output channel is actually based on, if any at all. Modifications that use data from other channels, such as masking using another data or tip convolution, should be represented as simple modifications of the primary channel.

Logging functions such as `gwy_log_add()` take settings values corresponding to the function name and store them in the log entry. If the settings are stored under a different name, use the "settings-name" logging option to set the correct name.

## Functions

### gwy_log_add_full()

    void
    gwy_log_add_full (GwyFile *file,
                      GwyDataKind data_kind,
                      gint previd,
                      gint newid,
                      const gchar *function,
                      ...);

Adds an entry to the log of data processing operations for a channel.

See the introduction for a description of valid `previd` and `newid` .

It is possible to pass `NULL` as `function` . In this case the log is just copied from source to target without adding any entries. This can be useful to prevent duplicate log entries in modules that modify a data field and then can also create secondary outputs. Note you still need to pass a second `NULL` argument as the argument list terminator.

#### Parameters

file | A data file container. |
data_kind | Type of the data object modified or created. |
previd | Identifier of the previous (source) data object of the same type in the container. Pass -1 for a no-source (or unclear source) operation or operations involving disparate data objects. |
newid | Identifier of the new (target) data object in the container. |
function | Quailified name of the function applied as shown by the module browser. For instance "image::facet-level" or "tool::GwyToolCrop". |
... | Logging options as a `NULL`-terminated list of pairs name, value. |

### gwy_log_add()

    void
    gwy_log_add (GwyFile *file,
                 GwyDataKind data_kind,
                 gint previd,
                 gint newid);

Adds an entry to the log of the current data processing operation.

This simplified variant of `gwy_log_add_full()` takes the currently running data processing function name for the corresponding data kind and constructs the qualified function name from that. The source and target data kinds need to be the same and correspond to the function type. If the function creates data of a different kind than the ‘natural’ kind for this type of function, you need `gwy_log_add_full()`.

Use `gwy_log_add_import()` to log data import from third party files and `gwy_log_add_synth()` to log data synthesis.

#### Parameters

file | A file data container. |
data_kind | Type of the data object. |
previd | Identifier of the previous (source) data object in the file. Pass -1 for a no-source (or unclear source) operation. |
newid | Identifier of the new (target) data object in the file. |

### gwy_log_add_import()

    void
    gwy_log_add_import (GwyFile *file,
                        GwyDataKind data_kind,
                        gint id,
                        const gchar *filetype,
                        const gchar *filename);

Logs the import of a data object from third-party file.

This is a convenience wrapper for `gwy_log_add_full()`. The source id will be set to -1. The file name will be added to function arguments.

#### Parameters

file | A data file container. |
data_kind | Type of the data object. |
id | Numerical id of a data in file. |
filetype | File type, i.e. the name of the function importing the data (without any "file::" prefix). It is possible to pass `NULL` to fill the name of the currently running file type function automatically. |
filename | Name of the imported file. If it is not valid UTF-8, it will be converted to UTF-8 using `g_filename_to_utf8()`. Failing even that, non-ASCII characters will be escaped. |

### gwy_log_add_synth()

    void
    gwy_log_add_synth (GwyFile *file,
                       GwyDataKind data_kind,
                       gint previd,
                       gint newid);

Adds an entry to the log of the current synthetic data operation.

This simplified variant of `gwy_log_add_full()` takes the currently running synthetic data function name for the corresponding data kind and constructs the qualified function name from that.

#### Parameters

file | A file data container. |
data_kind | Type of the data object. |
previd | Identifier of the initialisation data object in the file. Pass -1 if the data were generated from scatch, not by modification of existing data. |
newid | Identifier of the new data object in the file. |

### gwy_log_get_enabled()

    gboolean
    gwy_log_get_enabled (void);

Reports whether logging of data processing operations is globally enabled.

#### Returns

`TRUE` if logging is enabled, `FALSE` if it is disabled.

### gwy_log_set_enabled()

    void
    gwy_log_set_enabled (gboolean setting);

Globally enables or disables logging of data processing operations.

By default, logging is enabled. Non-GUI applications that run module functions may wish to disable it. Of course, the log will presist only if the data container is saved into a GWY file.

If logging is disabled logging functions such as `gwy_log_add()` become no-op. It is possible to run the log viewer with `gwy_log_browser()` to see log entries created when logging was enabled.

#### Parameters

setting | `TRUE` to enable logging, `FALSE` to disable it. |