Source file simple_log_output.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Stable = struct
  open Core.Core_stable

  module V1 = struct
    module Format = Async.Log.Output.Format.Stable.V1

    type t =
      | Stdout
      | Stderr
      | File of
          { format : Format.t
          ; filename : string
          }
    [@@deriving sexp]
  end
end

open Core
open Async
include Stable.V1

let stdout = lazy (Log.Output.writer `Sexp (force Writer.stdout))
let stderr = lazy (Log.Output.writer `Sexp (force Writer.stderr))

let to_output = function
  | Stdout -> Lazy.force stdout
  | Stderr -> Lazy.force stderr
  | File { format; filename } -> Log.Output.file format ~filename
;;