log

hoomd.logging.log(func=None, *, is_property=True, category='scalar', default=True, requires_run=False)

Creates loggable quantities for classes of type Loggable.

Use log() with hoomd.custom.Action to expose loggable quantities from a custom action.

Parameters:
  • func (method) – class method to make loggable. If using non-default arguments, func should not be set.

  • is_property (bool, optional) – Whether to make the method a property, defaults to True. Keyword only argument.

  • category (str, optional) – The string representation of the type of loggable quantity, defaults to ‘scalar’. See LoggerCategories for available types. Keyword only argument.

  • default (bool, optional) – Whether the quantity should be logged by default. Defaults to True. Keyword only argument.

  • requires_run (bool, optional) – Whether this property requires the simulation to run before being accessible.

Note

The namespace (where the loggable object is stored in the Logger object’s nested dictionary) is determined by the module/script and class name the loggable class comes from. In creating subclasses of hoomd.custom.Action, for instance, if the module the subclass is defined in is user.custom.action and the class name is Foo then the namespace used will be ('user', 'custom', 'action', 'Foo'). This helps to prevent naming conflicts and automates the logging specification for developers and users.

Example:

class LogExample(metaclass=hoomd.logging.Loggable):
    @log()
    def loggable(self):
        return 1.5

Note

The metaclass specification is not necessary for subclasses of HOOMD classes as they already use this metaclass.

See also

Tutorial: Custom Actions in Python