pub trait HasLogger {
    // Required methods
    fn init() -> Self;
    fn log_raw(&mut self, event: &[u8]) -> Result<(), LogError>;

    // Provided method
    fn log<S: Serial>(&mut self, event: &S) -> Result<(), LogError> { ... }
}
Expand description

Objects which can serve as loggers.

Logging functionality can be used by smart contracts to record events that might be of interest to external parties. These events are not used on the chain, and cannot be observed by other contracts, but they are stored by the node, and can be queried to provide information to off-chain actors.

In v1 contracts logging is per section of execution (between invoke_contract or invoke_transfer calls. In each section at most 64 items may be logged.

Required Methods§

source

fn init() -> Self

Initialize a logger.

source

fn log_raw(&mut self, event: &[u8]) -> Result<(), LogError>

Log the given slice as-is. If logging is not successful an error will be returned. The event can be no bigger than 512 bytes.

Provided Methods§

source

fn log<S: Serial>(&mut self, event: &S) -> Result<(), LogError>

Log a serializable event by serializing it with a supplied serializer. Note that the serialized event must be no larger than 512 bytes.

Implementors§

source§

impl HasLogger for Logger

#Implementations of the logger.

source§

impl HasLogger for TestLogger