• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Rust logging implementation for `log` which hooks to android log output

Send Rust logs to Logcat

Version CI status

This library is a drop-in replacement for env_logger. Instead, it outputs messages to android's logcat.

This only works on Android and requires linking to log which is only available under android. With Cargo, it is possible to conditionally require this library:

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11"

Example of initialization on activity creation, with log configuration:

#[macro_use] extern crate log;
extern crate android_logger;

use log::LevelFilter;
use android_logger::{Config,FilterBuilder};

fn native_activity_create() {
    android_logger::init_once(
        Config::default()
            .with_max_level(LevelFilter::Trace) // limit log level
            .with_tag("mytag") // logs will show under mytag tag
            .with_filter( // configure messages for specific crate
                FilterBuilder::new()
                    .parse("debug,hello::crate=error")
                    .build())
    );

    trace!("this is a verbose {}", "message");
    error!("this is printed by default");
}

To allow all logs, use the default configuration with min level Trace:

#[macro_use] extern crate log;
extern crate android_logger;

use log::LevelFilter;
use android_logger::Config;

fn native_activity_create() {
    android_logger::init_once(
        Config::default().with_max_level(LevelFilter::Trace),
    );
}

There is a caveat that this library can only be initialized once (hence the init_once function name). However, Android native activity can be re-created every time the screen is rotated, resulting in multiple initialization calls. Therefore this library will only log a warning for subsequent init_once calls.

This library ensures that logged messages do not overflow Android log message limits by efficiently splitting messages into chunks.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

rust-and-opengl-lessons

Collection of example code for learning OpenGL in Rust
Rust
379
star
2

di-rs

Dependency injection container for Rust
Rust
39
star
3

confluence-rs

Access and modify Atlassian Confluence pages from Rust
Rust
23
star
4

egli-rs

Easy to use EGL Interface for Rust
Rust
18
star
5

twig-rs

The Twig templating engine for Rust (work in progress).
Rust
18
star
6

embedded-experiments

C
12
star
7

android_log-sys-rs

Rust Bindings to Android log Library
Rust
12
star
8

tokio-proxy-rs

Simple TCP proxy server using tokio and futures.
Rust
12
star
9

cmake-cpp-docker

Docker image of various C++ compilers bundled with latest CMake version.
6
star
10

binser

A binary serializer for node.js
JavaScript
5
star
11

atom-rusty-dark-syntax

Rusty dark syntax theme for Atom
CSS
5
star
12

rust-mobile

Collection of scripts to build Rust for mobile platforms.
Shell
4
star
13

Nercury.github.io

Blog
CSS
4
star
14

octree-rs

Bounded octree structure
Rust
4
star
15

hack-the-crab

Firmware for embedded crab toy
Rust
4
star
16

little-rs

Little interpreter designed as fast template backend
Rust
3
star
17

metafactory-rs

Rust library for building factory chains at runtime.
Rust
3
star
18

memur

Arena storage with bells and whistles
Rust
3
star
19

vec-2-10-10-10-rs

A 32-bit vector, where 2 bits are dedicated to alpha, and 30 bits are dedicated to color. Compatible with GL_UNSIGNED_INT_2_10_10_10_REV vertex attribute format.
Rust
3
star
20

android_looper-rs

Thin wrapper for Android Looper.
Rust
2
star
21

email-spammer

A simple mailer that can send batch emails over gmail.
C#
2
star
22

rimworld-assign-animal-food

Rimworld mod to assign animal food restrictions
C#
2
star
23

typedef-rs

Rust library to identify or compare types, as well as print type names.
Rust
2
star
24

comics-rs

A simple web page that displays comics.
Rust
2
star
25

android_sensor-sys-rs

Bindings to Android Sensor Library
Rust
2
star
26

android_looper-sys-rs

Rust Bindings to Android Looper Library
Rust
2
star
27

inceptor-js

Ownership-driven dependency injection for JavaScript
JavaScript
1
star
28

specker-rs

Testing utility that simplifies file matching against bunch of templates.
Rust
1
star
29

gl_generator_profiling_struct-rs

ProfilingStructGenerator for gl_generator
Rust
1
star
30

gl-core-struct-rs

GL Core 4.5 profile, struct generator, Rc wrapper.
Rust
1
star
31

mobile-gl-rs

Rust
1
star
32

openocd

OpenOCD, modified to build
C
1
star