Class: Syskit::RobyApp::LoggingConfiguration
- Defined in:
- lib/syskit/roby_app/logging_configuration.rb
Overview
Management of the configuration related to logging of data streams and component configuration. The configuration for the running app can be accessed from
Syskit.conf.logs
Configuration logging is enabled or disabled with #enable_conf_logging and #disable_conf_logging. Configuration logging being low-bandwidth, there's no way to fine-tune what should or should not be logged.
Port logging can be globally disabled with #disable_port_logging. When logging is enabled (the default, or after calling #enable_port_logging), which ports will actually be logged is controlled by log groups. Log groups match certain ports by deployment, task, port name or port type. A port will be excluded from the logs if there is at least one group matching it, and that all groups are disabled.
In other words:
- ports are logged if no groups match them
- ports will be logged if there is at least one enabled group matching them
- the only case where a port is excluded from logs is when all groups
matching it are disabled
Groups are defined with #create_group and enabled/disabled with #enable_group/#disable_group. A new group is enabled by default.
Logs groups are usually defined in a robot file, in a Robot.conf block:
Robot.conf do
Syskit.conf.logs.create_group 'Images' do
add /base.samples.frame.Frame/
end
end
From then, the Images group can be disabled programatically from within the Roby app with
Syskit.conf.logs.disable_log_group 'Images'
Or from the Roby shell with (note that it triggers a redeploy)
syskit.disable_log_group 'Images'
And then reenabled with
Syskit.conf.logs.enable_log_group 'Images'
syskit.enable_log_group 'Images'
Instance Attribute Summary collapse
-
#configuration_log ⇒ Object
The configuration log file.
-
#default_logging_buffer_size ⇒ Integer
The default buffer size that should be used when setting up a logger connection.
-
#groups ⇒ Hash<String,LoggingGroup>
readonly
The set of defined groups.
Instance Method Summary collapse
-
#conf_logs_enabled? ⇒ Object
If true, changes to the values in configuration values are being logged by the framework.
-
#create_configuration_log(path) ⇒ Object
Create the configuration log file.
-
#create_group(name, enabled: true) {|group| ... } ⇒ Object
Create a new log group with the given name.
-
#disable_conf_logging ⇒ Object
See #conf_log_enabled?.
-
#disable_log_group(name) ⇒ Object
Turns logging off for the named group.
-
#disable_port_logging ⇒ Object
See #log_enabled?.
-
#enable_conf_logging ⇒ Object
See #conf_log_enabled?.
-
#enable_log_group(name) ⇒ Object
Turns logging on for the named group.
-
#enable_port_logging ⇒ Object
See #log_enabled?.
-
#group_by_name(name) ⇒ LoggingGroup
Fetch a group by its name.
-
#initialize ⇒ LoggingConfiguration
constructor
A new instance of LoggingConfiguration.
-
#log_stream_for(property) ⇒ Object
Returns the log stream that should be used for modifications to the given property.
-
#object_excluded_from_log? {|log_group| ... } ⇒ Boolean
private
Helper method to test whether an object is excluded from log.
-
#port_excluded_from_log?(port) ⇒ Boolean
Returns true if the given port is excluded from logging.
-
#port_logs_enabled? ⇒ Object
Signifies whether ports (i.e. data streams between components) is enabled at all or not.
-
#remove_group(name) ⇒ Object
Remove a group.
-
#update_group(name) {|group_by_name(name)| ... } ⇒ Object
Update an existing logging group.
Constructor Details
#initialize ⇒ LoggingConfiguration
Returns a new instance of LoggingConfiguration
54 55 56 57 58 59 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 54 def initialize @groups = Hash.new @port_logs_enabled = true @conf_logs_enabled = true @default_logging_buffer_size = 25 end |
Instance Attribute Details
#configuration_log ⇒ Object
The configuration log file
87 88 89 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 87 def configuration_log @configuration_log end |
#default_logging_buffer_size ⇒ Integer
The default buffer size that should be used when setting up a logger connection
Defaults to 25
72 73 74 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 72 def default_logging_buffer_size @default_logging_buffer_size end |
#groups ⇒ Hash<String,LoggingGroup> (readonly)
The set of defined groups
64 65 66 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 64 def groups @groups end |
Instance Method Details
#conf_logs_enabled? ⇒ Object
If true, changes to the values in configuration values are being logged by the framework. If false, they are not.
Currently, properties are logged in a properties.0.log file
80 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 80 attr_predicate :conf_logs_enabled? |
#create_configuration_log(path) ⇒ Object
Create the configuration log file
90 91 92 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 90 def create_configuration_log(path) @configuration_log = Pocolog::Logfiles.create(path) end |
#create_group(name, enabled: true) {|group| ... } ⇒ Object
Create a new log group with the given name
136 137 138 139 140 141 142 143 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 136 def create_group(name, enabled: true) if groups[name.to_str] raise ArgumentError, "there is already a group registered under the name #{name}, use #update_group if you mean to update it" end group = LoggingGroup.new(enabled) yield(group) if block_given? groups[name.to_str] = group end |
#disable_conf_logging ⇒ Object
See #conf_log_enabled?
84 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 84 def disable_conf_logging; @conf_logs_enabled = false end |
#disable_log_group(name) ⇒ Object
Turns logging off for the named group. The modification will only be applied at the next network generation.
197 198 199 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 197 def disable_log_group(name) group_by_name(name.to_s).enabled = false end |
#disable_port_logging ⇒ Object
See #log_enabled?
117 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 117 def disable_port_logging; @port_logs_enabled = false end |
#enable_conf_logging ⇒ Object
See #conf_log_enabled?
82 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 82 def enable_conf_logging; @conf_logs_enabled = true end |
#enable_log_group(name) ⇒ Object
Turns logging on for the named group. The modification will only be applied at the next network generation.
189 190 191 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 189 def enable_log_group(name) group_by_name(name.to_s).enabled = true end |
#enable_port_logging ⇒ Object
See #log_enabled?
115 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 115 def enable_port_logging; @port_logs_enabled = true end |
#group_by_name(name) ⇒ LoggingGroup
Fetch a group by its name
123 124 125 126 127 128 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 123 def group_by_name(name) if group = groups[name.to_s] group else raise ArgumentError, "no group named #{name}" end end |
#log_stream_for(property) ⇒ Object
Returns the log stream that should be used for modifications to the given property
96 97 98 99 100 101 102 103 104 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 96 def log_stream_for(property) stream_name = "#{property.task_context.orocos_name}.#{property.name}" if !configuration_log.has_stream?(stream_name) configuration_log.create_stream( stream_name, property.type, property.) else configuration_log.stream(stream_name) end end |
#object_excluded_from_log? {|log_group| ... } ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Helper method to test whether an object is excluded from log
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 165 def object_excluded_from_log? return true if !port_logs_enabled? has_one_match = false groups.each_value do |group| if yield(group) return false if group.enabled? has_one_match = true end end return has_one_match end |
#port_excluded_from_log?(port) ⇒ Boolean
Returns true if the given port is excluded from logging
181 182 183 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 181 def port_excluded_from_log?(port) object_excluded_from_log? { |g| g.matches_port?(port) } end |
#port_logs_enabled? ⇒ Object
Signifies whether ports (i.e. data streams between components) is enabled at all or not. If false, no logging will take place. If true, logging is enabled to the extent of the log configuration done with enable/disable log groups (#enable_log_group) and single ports (#exclude_from_log)
113 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 113 attr_predicate :port_logs_enabled? |
#remove_group(name) ⇒ Object
Remove a group
154 155 156 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 154 def remove_group(name) groups.delete(name.to_str) end |
#update_group(name) {|group_by_name(name)| ... } ⇒ Object
Update an existing logging group
149 150 151 |
# File 'lib/syskit/roby_app/logging_configuration.rb', line 149 def update_group(name) yield(group_by_name(name)) end |