Skip to content

Commit

Permalink
Merge pull request #4 from p2panda/adz/tracing
Browse files Browse the repository at this point in the history
Diagnostics with tracing
  • Loading branch information
adzialocha authored Dec 16, 2024
2 parents 67267ac + 8a771bf commit ca4094a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
# Aardvark
# Aardvark (working title)

MVP local-first text editor :)
MVP collaborative, local-first GTK text editor :)

## Getting Started
## Development

### Getting Started

The [GNOME Builder IDE](https://builder.readthedocs.io/) is required to build
and run the project. It can be installed with flatpak.

1. [Install flatpak](https://flatpak.org/setup/) for your distribution.

2. Install [Builder](https://flathub.org/apps/org.gnome.Builder) for GNOME:

`flatpak install flathub org.gnome.Builder`

3. Clone the aardvark repo:

`git clone git@github.com:p2panda/aardvark.git && cd aardvark`

4. Open the Builder application and navigate to the aardvark repo.
- You may be prompted to install or update the SDK in Builder.

5. Run the project with `Shift+Ctrl+Space` or click the ► icon (top-middle of
the Builder appication).

6. Run builder in a separate dbus session if you need multiple instances to
test the application:
### Multiple instances

Run builder in a separate dbus session if you need multiple instances to test
the application: `dbus-run-session org.gnome.Builder`.

### Diagnostics

`dbus-run-session org.gnome.Builder`
Set the `RUST_LOG` environment variable to your verbosity setting and filter to
enable log-based diagnostics with [tracing](https://docs.rs/tracing). Example:
`RUST_LOG=debug` or `RUST_LOG=p2panda_net=INFO` etc.

## Todo

Expand Down
1 change: 1 addition & 0 deletions aardvark-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gtk = { version = "0.9", package = "gtk4", features = ["gnome_47"] }
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.128"
tokio = { version = "1.42.0", features = ["full"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[dependencies.adw]
package = "libadwaita"
Expand Down
24 changes: 18 additions & 6 deletions aardvark-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ mod textbuffer;
mod window;

use std::path::PathBuf;
use self::application::AardvarkApplication;
use self::textbuffer::AardvarkTextBuffer;
use self::window::AardvarkWindow;


use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR};
use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain};
use gtk::prelude::*;
use gtk::{gio, glib};
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;

use self::application::AardvarkApplication;
use self::config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR};
use self::textbuffer::AardvarkTextBuffer;
use self::window::AardvarkWindow;

fn main() -> glib::ExitCode {
setup_logging();

// Set up gettext translations
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain");
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8")
Expand Down Expand Up @@ -65,7 +69,7 @@ fn get_pkgdatadir() -> PathBuf {
let exe_path = std::env::current_exe().expect("Failed to get current executable path");
// Navigate to the 'Resources/share/aardvark' directory relative to the executable
exe_path
.parent() // Goes up to 'Contents/MacOS'
.parent() // Goes up to 'Contents/MacOS'
.and_then(|p| p.parent()) // Goes up to 'Contents'
.map(|p| p.join("Resources/share/aardvark"))
.expect("Failed to compute PKGDATADIR")
Expand All @@ -76,3 +80,11 @@ fn get_pkgdatadir() -> PathBuf {
PathBuf::from(PKGDATADIR)
}
}

fn setup_logging() {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_writer(std::io::stderr))
.with(EnvFilter::from_default_env())
.try_init()
.ok();
}
5 changes: 4 additions & 1 deletion org.p2panda.aardvark.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"--device=dri",
"--socket=wayland",
"--env=RUST_BACKTRACE=1",
"--env=RUST_LOG=aardvark=debug"
"--env=RUST_LOG=debug"
],
"build-options" : {
"append-path" : "/usr/lib/sdk/rust-stable/bin",
Expand Down Expand Up @@ -44,6 +44,9 @@
"url" : "./",
"branch" : "HEAD"
}
],
"config-opts" : [
"--libdir=lib"
]
}
]
Expand Down

0 comments on commit ca4094a

Please sign in to comment.