Giter VIP home page Giter VIP logo

flutter_logger's Introduction

flutter_logger

implementation of the log crate for using rust together with flutter/dart and flutter_rust_bridge to get logs from rust into your app.

features

  • panic: print rust panics to the log stream.

usage

The library contains a macro for all the code you have to include in your flutter_rust_bridge api definition. Calling the macro without args creates the init function "setup_log_stream" with LeveFilter::Debug. You can also specify function name and LevelFilter (or only one). The macro can only be called once because of conflicting implementations

rust

// only one of these calls can be active
flutter_logger::flutter_logger_init!(); // default
// flutter_logger::flutter_logger_init!(LeveFilter::Trace); // sepcify level
// flutter_logger::flutter_logger_init!(logger_init); // sepcify name
// flutter_logger::flutter_logger_init!(info_logger, LevelFilter::Info); // sepcify both

pub fn test(i: i32) {
    // using the 'log' crate macros
    info!("test called with: {i}")
}

dart/flutter

void setupLogger(){
    setupLogStream().listen((msg){
    // This should use a logging framework in real applications
        print("${msg.logLevel} ${msg.lbl.padRight(8)}: ${msg.msg}");
    });
}

void main(){
    await RustLib.init();
    await setupLogger();
    await test(i: 5);
}

This works also on mobile apps like Android where println() in rust isn't shown in the console.

flutter_logger's People

Contributors

mnlphlp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.