Example configurations#

Here shows some example full configurations.

Example configuration to use the default log sink to write to console#

examples/logging/configs/use_default_log_sink.toml#
# Example configuration to use the default log sink (a log sink to write to console).

# Schema.
"$schema" = "https://numcollect.musicscience37.com/config_schema/v2/config_schema.json"

# Default configuration for log tags. (Optional.)
[[num_collect.logging.tag_configs]]

# Log tag. (Required.)
# Empty string specifies the default configuration.
tag = ""

# Name of a log sink. (Optional.)
# Log sink with this name must be configured in
# num_collect.logging.sinks configuration (written below) in the same file,
# or use "default" log sink in this library.
sink = "default"

# Minimum log level to output. (Optional.)
# Choices: trace, debug, iteration, summary, info, warning, error, critical, off.
output_log_level = "iteration"

# Minimum log level to output in child iterations. (Optional.)
# Choices are same as output_log_level.
output_log_level_in_child_iterations = "info"

# Period to write iteration logs. (Optional.)
iteration_output_period = 10

# Period to write labels of iteration logs. (Optional.)
iteration_label_period = 20

Example configuration to write to a file#

examples/logging/configs/write_to_single_file.toml#
# Example configuration to write to a file.

# Schema.
"$schema" = "https://numcollect.musicscience37.com/config_schema/v2/config_schema.json"

# Default configuration for log tags. (Optional.)
[[num_collect.logging.tag_configs]]

# Log tag. (Required.)
# Empty string specifies the default configuration.
tag = ""

# Name of a log sink. (Optional.)
# Log sink with this name must be configured in
# num_collect.logging.sinks configuration (written below) in the same file,
# or use "default" log sink in this library.
sink = "file sink"

# Minimum log level to output. (Optional.)
# Choices: trace, debug, iteration, summary, info, warning, error, critical, off.
output_log_level = "iteration"

# Minimum log level to output in child iterations. (Optional.)
# Choices are same as output_log_level.
output_log_level_in_child_iterations = "info"

# Period to write iteration logs. (Optional.)
iteration_output_period = 10

# Period to write labels of iteration logs. (Optional.)
iteration_label_period = 20

[[num_collect.logging.sinks]]

# Name of the log sink. (Required.)
name = "file sink"

# Type of the log sink. (Required.)
type = "single_file"

# Filepath. (Required.)
filepath = "num_collect_ex_write_logs.log"

Example configuration to write to console and file#

examples/logging/configs/write_to_console_and_file.toml#
# Example configuration to write to console and file.

# Schema.
"$schema" = "https://numcollect.musicscience37.com/config_schema/v2/config_schema.json"

# Default configuration for log tags. (Optional.)
[[num_collect.logging.tag_configs]]

# Log tag. (Required.)
# Empty string specifies the default configuration.
tag = ""

# Name of a log sink. (Optional.)
# Log sink with this name must be configured in
# num_collect.logging.sinks configuration (written below) in the same file,
# or use "default" log sink in this library.
sink = "console file sink"

# Minimum log level to output. (Optional.)
# Choices: trace, debug, iteration, summary, info, warning, error, critical, off.
output_log_level = "trace"

# Minimum log level to output in child iterations. (Optional.)
# Choices are same as output_log_level.
output_log_level_in_child_iterations = "info"

# Period to write iteration logs. (Optional.)
iteration_output_period = 10

# Period to write labels of iteration logs. (Optional.)
iteration_label_period = 20

# Combined log sink to write to console and file.
[[num_collect.logging.sinks]]

# Name of the log sink. (Required.)
name = "console file sink"

# Type of the log sink. (Required.)
type = "combined"

# Log sinks used to actual logging. (Required.)
# Log sink with these names must be configured in the same file.
inner_sink_names = ["file sink", "console sink"]

# Minimum log levels to output. (Required.)
# Number of elements must be same with inner_sink_names.
output_log_levels = ["trace", "info"]

# Log sink to write to console.
[[num_collect.logging.sinks]]

# Name of the log sink. (Required.)
name = "console sink"

# Type of the log sink. (Required.)
type = "console"

# Whether to use color. (Optional.)
use_color = true

# Log sink to write to a single file.
[[num_collect.logging.sinks]]

# Name of the log sink. (Required.)
name = "file sink"

# Type of the log sink. (Required.)
type = "single_file"

# Filepath. (Required.)
filepath = "num_collect_ex_write_logs.log"