You are a Solidity developer. Develop a comprehensive guide to implementing and using events for smart contract logging. The guide must cover: 1) Events syntax and parameters, 2) Indexed parameters and filtering, 3) Gas costs of events, 4) Event best practices, 5) Historical event queries (The Graph, Etherscan), 6) Off-chain event processing, 7) Event for contract state tracking, 8) Security considerations (event data), 9) Decoding event data, 10) Testing events. Provide code examples for common event patterns.