A standalone, `#![no_std]`-friendly `Logger` crate.

Related tags

Logging printk
Overview

A standalone, #![no_std]-friendly Logger crate. Based on the design of the logger built into the bootloader crate and meant to be used in OS kernels.

To use this crate, specify it as a dependency in your kernel's Cargo.toml, then initialize it.

Initialization

The logger needs to be initialized in order to be used. To do that, one must first create a global instance, using a crate like conquer_once:

pub static PRINTK: OnceCell
   
     = OnceCell::uninit();

   

After this, the log crate needs to be attached to it. This requires the following 3 steps:

  1. Use the get_or_init method to unwrap the LockedPrintk object from its outer OnceCell
  2. Use log::set_logger to tell the log crate what to attach to
  3. Use log::set_max_level to tell the log crate how many levels of logging you want to do

Here's an example function demonstrating how this is done in pure Rust:

pub fn printk_init(buffer: &'static mut [u8], info: FrameBufferInfo) {
    let kernel_logger = printk::PRINTK.get_or_init(move || printk::LockedPrintk::new(buffer, info));
    log::set_logger(kernel_logger).expect("logger already set");
    log::set_max_level(log::LevelFilter::Trace);
    log::info!("Hello, Kernel!");
}

Contributing

If you have any functionality to add, feel free to create a pull request. I'll gladly test and accept it. Also, if you have any bugs to report, that is also what GitHub is for.

You might also like...
Cryptography-oriented big integer library with constant-time, stack-allocated (no_std-friendly) implementations of modern formulas

RustCrypto: Cryptographic Big Integers Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptog

A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice
A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice

sensible-env-logger A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice. This is a thin wrapper around pret

A pretty, easy-to-use logger for Rust.
A pretty, easy-to-use logger for Rust.

pretty-env-logger A simple logger built on top of env_logger. It is configured via an environment variable and writes to standard error with nice colo

A Rust logger with various features.

Moe Logger (>ω<) Another logger based on pretty-env-logger and env_logger. Allow writing log to file with features like formatting, file rotation. Usa

A loki logger for the log facade

Loki Logger A loki logger for the log facade. Examples extern crate log; extern crate loki_logger; use log::LevelFilter; #[tokio::main] async fn main

HTTP request logger

nosy - HTTP request logger How hard can it be to build your own HTTP request logger in Rust? Well, not that easy if you've never written a webapp in R

Another Key Logger Yet. Rust.

Another Key Logger Yet. Rust. For my very first experience of working with Rust, I decided to manage the keyboard, this time by logging and writing th

Rall is an incredibly simple and intuitive logger
Rall is an incredibly simple and intuitive logger

Really...? Another Logging Library? Yes! :P rall is an incredibly simple and intuitive logger, consider this crate a failure if you can't get setup wi

API and logger for GBFS endpoints, noticeably Velib' in Paris

GBFS Watcher A daemon which logs Velib' stations statuses and provides a REST endpoint to access data. Velib' API is built over GBFS v1, so this API c

🔥 📝  (fwdt)
🔥 📝 (fwdt) "few word do trick" is a cross platform manual fast logger

Few Word Do Trick (fwdt) Few Word Do Trick (fwdt) is a cross-platform general purpose fast logger for humans that supports incomplete csvs for a bette

A dead simple logger that works globally and across threads.

Woody A logger for Rust that's *actually* easy to use. Features Easy to use: Just import the macros and you're good to go. No need to configure anythi

⚙️ Pre-commit hook for downgrading Python logger syntax

printf-log-formatter Automatically convert f-strings and str.format() syntax to printf-style strings. In other words, this syntax logger.error(f"{1}")

Drop-in replacement for the Actix Web HTTP Logger middleware

actix-contrib-logger Logger middleware for the Actix Web framework. Actually it's a copy & paste from the official Logger middleware (original source

Linear Programming for Rust, with an user-friendly API. This crate allows modeling LP problems, and let's you solve them with various solvers.

good_lp A Linear Programming modeler that is easy to use, performant with large problems, and well-typed. use good_lp::{variables, variable, coin_cbc,

A tilemap rendering crate for bevy which is more ECS friendly.
A tilemap rendering crate for bevy which is more ECS friendly.

bevy_ecs_tilemap A tilemap rendering plugin for bevy which is more ECS friendly by having an entity per tile. Features A tile per entity Fast renderin

A friendly parser combinator crate

Chumsky A friendly parser combinator crate that makes writing LL-1 parsers with error recovery easy. Example Here follows a Brainfuck parser. See exam

Advanced Fuzzing Library - Slot your Fuzzer together in Rust! Scales across cores and machines. For Windows, Android, MacOS, Linux, no_std, ...
Advanced Fuzzing Library - Slot your Fuzzer together in Rust! Scales across cores and machines. For Windows, Android, MacOS, Linux, no_std, ...

LibAFL, the fuzzer library. Advanced Fuzzing Library - Slot your own fuzzers together and extend their features using Rust. LibAFL is written and main

This is a Rust implementation for popular caches (support no_std).

Caches This is a Rust implementation for popular caches (support no_std). See Introduction, Installation and Usages for more details. English | 简体中文 I

A feature-few, no-allocation JSON parser in `no_std` rust.

Small JSON Parser in no_std This library reads and parses JSON strings. Its intended use case is to read a JSON payload once. It does not serialise da

Owner
Kenny Strawn
Christian apologist, electronic musician, and OSS enthusiast
Kenny Strawn
A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice

sensible-env-logger A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice. This is a thin wrapper around pret

Ritvik Nag 3 Aug 9, 2022
A pretty, easy-to-use logger for Rust.

pretty-env-logger A simple logger built on top of env_logger. It is configured via an environment variable and writes to standard error with nice colo

Sean McArthur 390 Dec 29, 2022
A Rust logger with various features.

Moe Logger (>ω<) Another logger based on pretty-env-logger and env_logger. Allow writing log to file with features like formatting, file rotation. Usa

Rui Li 4 Sep 24, 2021
A loki logger for the log facade

Loki Logger A loki logger for the log facade. Examples extern crate log; extern crate loki_logger; use log::LevelFilter; #[tokio::main] async fn main

Thomas Nicollet 11 Dec 24, 2022
HTTP request logger

nosy - HTTP request logger How hard can it be to build your own HTTP request logger in Rust? Well, not that easy if you've never written a webapp in R

Manuel Hutter 1 Nov 26, 2021
Another Key Logger Yet. Rust.

Another Key Logger Yet. Rust. For my very first experience of working with Rust, I decided to manage the keyboard, this time by logging and writing th

(Not) Kearash 0 May 3, 2022
Rall is an incredibly simple and intuitive logger

Really...? Another Logging Library? Yes! :P rall is an incredibly simple and intuitive logger, consider this crate a failure if you can't get setup wi

Hamothy 4 Sep 5, 2022
A dead simple logger that works globally and across threads.

Woody A logger for Rust that's *actually* easy to use. Features Easy to use: Just import the macros and you're good to go. No need to configure anythi

Travis A. Wagner 11 Apr 13, 2023
godot-logger is an easy-to-use logger for godot-rust projects.

godot-logger is an easy-to-use logger for godot-rust projects. It prints logs to Godot's output console and supports module-specific log levels.

Jan David 10 Nov 17, 2022
A crate for working with Ethereum beacon chain light client protocol messages. `no_std` friendly!

eth-lightclient-rs A crate for working with Ethereum beacon chain light client protocol messages. no_std friendly! !! For hacking and experimentation

Willem Olding 12 Jan 6, 2023