New Package: Journal.jl


I would like to announce a new logging package we have developed and are using in a number of internal projects:

Journal.jl is currently unregistered but development has stabilised.
Any feedback would be appreciated :slight_smile:

To install it, simply run:

julia> Pkg.clone("")

Journal.jl is an extensible hierarchical logging framework for Julia with
multiple output targets, including:

  • Streams: Console, File, etc
  • Google Datastore (via GoogleCloud.jl)
  • Arbitrary webhook APIs (e.g. Slack) with ability to authenticate via custom

Loggers can be configured hierarchically, with child loggers set to log at different
levels or to different targets.

Data stored by Journal.jl can also be read back later from a specific store.

Additional features (undocumented but finished) include defining metrics to be applied to stored log data.

Basic Usage

Journal.jl is generally configured via YAML. The YAML format specifies:

  • stores with associated:
    • store type: e.g. io, datastore, webhook or some custom registered type
    • plus configuration relevant to the specific store type
  • loggers with associated:
    • log level: (DEBUG < INFO < WARN < ERROR)
    • target stores: referencing a store definition
    • dependent children: referencing child loggers that are to be passed the same messages as the parent

Here is a simple configuration file:

# journal.yml
    type: io
    type: io
    file: [journal.log, w+]
    format: "$timestamp: $level: $name: topic=$topic; message=$message; value=$value"
    level: DEBUG
    stores: [console]
    children: [disk]
    level: INFO
    stores: [file]

Journal can now be set up from the configuration file:

using Journal

Use the loggers:

# use default "root" logger (screen)"Is this thing on?")

# specify topic (overrides line func[file:line])"Helllloooooo"; topic="greeting")

# attach a value to the message"Testing, Testing"; value=[1, 2, 3], topic="mic_check")
Journal.warn("Check"; value=[1, 2], topic="mic_check")

# override the timestamp"A long time ago in a galaxy far far away..."; timestamp=DateTime("1977-05-25"), topic="star wars")

# add custom tags"Exterminate"; topic="threat", species="dalek", source="Davros")

# log to a specific logger
logger = getlogger(:screen)
Journal.debug(logger, "Can you hear me?")  # note: not stored to "disk" logger since DEBUG < INFO

# or using a do block
getlogger(:disk) do logger
    Journal.warn(logger, "Don't touch that!")
    Journal.error(logger, "ZAP")

Journal can also read back log data:

using DataTables
using Base.Dates

store = getstore(:file)
records = read(store)
table = DataTable(records)

# apply a filter to the data
mic_checks = read(store; filter=Dict(:topic => "mic_check"))

# apply a timestamp filter [start, finish]
recent = read(store; start=now(UTC) - Day(1), finish=now(UTC))

See for more detail.