How meituan-dianping/logan works
Project Type and Purpose
• Logan is a full-stack logging system that spans multiple platforms (iOS, Android, Web, Flutter, etc.). Its purpose is to collect, store, upload, and analyze logs generated across different client applications.
• The project is split into several distinct SDKs (for mobile and web), a server component (backend log processing and storage), and a visual front-end (LoganSite) for analysis and search.
File Structure
• Notice that there are multiple top-level directories for each client platform:
– Example/Logan-Android (Android SDK sample and integration)
– Logan/Logan (includes the core C logging library “Clogan” and encryption utilities)
– Logan/iOS (iOS SDK)
– Logan/WebSDK (JavaScript SDK for web environments)
– Flutter (Flutter plugin supporting Android/iOS)
• In addition, there is a backend server directory (Logan/Server) and a frontend web UI in Logan/LoganSite.
• Also, supporting libraries like mbedtls and cJSON reside under Logan/mbedtls and Logan/Clogan, indicating that the low-level logging libraries and encryption components are built in C.
• The presence of NodeServer examples, Dockerfiles, and package files indicates that the project is designed to be deployed in varied environments with typical configurations (build and deployment scripts).
README for Insights
• The README explains the architecture with multiple images, describing four core modules: Input, Storage, BackEnd, and FrontEnd.
• It outlines a logging “pipeline” where logs are generated by the clients (via SDKs), sent to the server, stored/processed, and then visualized via LoganSite.
• There are also step-by-step setup instructions and environment requirements for each component, reaffirming the separation of concerns by platform.
• Main Components:
• Mobile and Client SDKs:
· iOS SDK (Logan/iOS) and macOS components.
· Android SDK (Example/Logan-Android and Logan/Logan through C components).
· Flutter Plugin (Flutter) that wraps the logging functionality.
· Web SDK (Logan/WebSDK) for browser-based logging.
• Server Side:
· Backend log processing service (Logan/Server) written in Java.
· Supporting log file management, protocol handling, and batch insertion.
· Configuration via Dockerfiles, pom.xml, and migration scripts (in Logan/scripts).
• Frontend:
· LoganSite (Logan/LoganSite) which provides a visual interface for log search & analysis.
· This is a Node/React-based web application that communicates with the Backend via an API.
• Core Logging Library:
· The low-level C library (Clogan in Logan/Clogan) that handles log formatting/processing.
· The integration with mbedtls and cJSON for security and structured log messaging.
• Relationships/Interactions:
• Client SDKs generate logs and use a common protocol (as detailed in the README’s “Log protocol” documentation) to send logs to the backend.
• The server receives logs, processes them (using modules like protocol handlers, task dispatchers, and mappers), and stores them (possibly in a database, as hinted by SQL scripts and migration files).
• LoganSite acts as a monitoring and analysis layer that communicates with the backend to retrieve log details (through defined APIs).
• The use of native libraries (C language libraries and mobile platform project files) indicates integration via JNI (for Android) or direct SDK bindings (for iOS and Flutter).