def serialize_object(obj):
    # Try to serialize the object
    if getattr(obj, 'to_dict', None):
        value = obj.to_dict()
    elif getattr(obj, 'to_serializable_dict', None):
        value = obj.to_serializable_dict(mask_secrets=True)
    else:
        value = repr(obj)

    return value
Serialize the provided object.
dataset/ETHPy150Open StackStorm/st2/st2common/st2common/logging/formatters.py/serialize_object