[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MirageOS-devel] mirage-logs and functoria



mirage-logs is a log reporter for the Logs library that works with
Mirage unikernels.

  https://github.com/talex5/mirage-logs

Basic usage looks like this:

module Main (Clock : V1.CLOCK) = struct
  module Log_reporter = Mirage_logs.Make(Clock)

  let start () =
    Log_reporter.(create () |> run) @@ fun () ->
    ...

Log messages are generated using the normal Logs API (0.5.0). e.g.

let src = Logs.Src.create "unikernel" ~doc:"Main unikernel code"
module Log = (val Logs.src_log src : Logs.LOG)

...

Log.info (fun f -> f "agents connected in %.3f s (CPU time used since
boot: %.3f s)"
  (Clock.time () -. start_time) (Sys.time ()));

( I originally had mirage-logs writing to a Mirage CONSOLE device, but
that's asynchronous. That meant that I had to queue messages, drop
messages when the queue got too long etc. And if the unikernel
crashed, you wouldn't see the latest messages. Instead, it now writes
to stderr, which is blocking on Unix and Xen. This means that if you
generate a lot of logging output then your unikernel may run slowly,
but you will get all the messages. )

Sample output:

MirageOS booting...
Initialising timer interface
Initialising console ... done.
Netif: add resume hook
gnttab_stubs.c: initialised mini-os gntmap
2016-01-12 11:45.09: INF [qubes.rexec] waiting for client...
2016-01-12 11:45.09: INF [qubes.gui] waiting for client...
2016-01-12 11:45.09: INF [qubes.db] connecting to server...
2016-01-12 11:45.09: INF [qubes.db] connected
2016-01-12 11:45.09: INF [qubes.rexec] client connected, using
protocol version 2

Extra features:

If log messages include tags, these are also printed.

If tracing is enabled (with mirage-profile) then any log message
reaching the reporter is also written to the trace buffer, and will
appear in the viewer.

You can specify a threshold function for console messages, so that
detailed logging can be written to the trace buffer but only important
messages are displayed on the console.

You can also configure a ring buffer for log messages. Any message
received by the reporter (whether shown on the console or not) will be
written to the ring. If an exception occurs, the contents of the ring
are dumped to stderr. e.g.

let console_threshold src =
  match Logs.Src.name src with
  | "noisy.library" -> Logs.Warning
  | _ -> Logs.Info in
Logs_reporter.(create ~ring_size:20 ~console_threshold () |> run) @@ fun () ->
...

Ideally, I'd like to integrate this with functoria. What would be the
best way to do this?
Is it possible to do something like this?

  register "console" [mirage_logs (main $ default_console)]


-- 
Dr Thomas Leonard        http://roscidus.com/blog/
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.