Skip to content

feature-complete interface #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion logger/interface/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v17.9.1
v17.9.1
12 changes: 9 additions & 3 deletions logger/interface/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"name": "@polywrap/logging-interface",
"description": "Polywrap Logging Interface",
"version": "0.10.0",
"scripts": {
"build": "polywrap build",
"deploy": "polywrap deploy -o deployment.json"
"build": "npx polywrap build",
"deploy": "npx polywrap deploy -o deployment.json"
},
"devDependencies": {
"polywrap": "0.10.2"
"polywrap": "0.10.3"
},
"publishConfig": {
"access": "public"
}
}
99 changes: 92 additions & 7 deletions logger/interface/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -1,13 +1,98 @@
type Module {
"""
Logs a message with the specified log level, message content, and context, then returns the created LogEntry.
"""
log(level: LogLevel!, message: String!, context: String): LogEntry!

"""
Logs a trace-level message with the specified message content and context, then returns the created LogEntry.
"""
trace(message: String!, context: String): LogEntry!

"""
Logs a debug-level message with the specified message content and context, then returns the created LogEntry.
"""
debug(message: String!, context: String): LogEntry!

"""
Logs an info-level message with the specified message content and context, then returns the created LogEntry.
"""
info(message: String!, context: String): LogEntry!

"""
Logs a warning-level message with the specified message content and context, then returns the created LogEntry.
"""
warn(message: String!, context: String): LogEntry!

"""
Logs an error-level message with the specified message content and context, then returns the created LogEntry.
"""
error(message: String!, context: String): LogEntry!

"""
Logs a fatal-level message with the specified message content and context, then returns the created LogEntry.
"""
fatal(message: String!, context: String): LogEntry!

"""
Changes the minimum log level at runtime, returning true if successful.
"""
setLogLevel(level: LogLevel!): Boolean!

"""
Returns the current log level.
"""
getLogLevel: LogLevel!

"""
Retrieves a specific log entry by its ID.
"""
getLog(id: Int!): LogEntry

"""
Retrieves a list of logs, optionally filtered by the specified log level.
"""
getLogs(level: LogLevel): [LogEntry!]!
}

"""
Represents the various log levels.
"""
enum LogLevel {
DEBUG
INFO
WARN
ERROR
TRACE
DEBUG
INFO
WARN
ERROR
FATAL
}

type Module {
log(
"""
Defines the structure of a log entry.
"""
type LogEntry {
"""
The unique identifier of the log entry.
"""
id: Int!

"""
The timestamp of the log entry in ISO 8601 format.
"""
timestamp: String!

"""
The log level of the log entry.
"""
level: LogLevel!

"""
The message content of the log entry.
"""
message: String!
): Boolean!

"""
The context associated with the log entry, if any.
"""
context: String
}
3 changes: 1 addition & 2 deletions logger/interface/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
format: 0.3.0
project:
name: logger-interface
name: logging-interface
type: interface
source:
schema: ./polywrap.graphql
resources: ./resources
60 changes: 43 additions & 17 deletions logger/interface/resources/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
# Logger Wrapper Interface
A simple logger interface, to be implemented by a wrapper.
# Logging Wrapper Interface

| Version | URI | WRAP Standard |
| Version | URI | WRAP Version |
|-|-|-|
| 1.0.0 | [`wrap://ens/wraps.eth:logger@1.0.0`](https://wrappers.io/v/ens/wraps.eth:logger@1.0.0) | 0.1 |
| 1.0.0 | [`wrap://ens/wraps.eth:logging@1.0.0`](https://wrappers.io/v/ens/wraps.eth:logging@1.0.0) | 0.1 |

## Interface
```graphql
type Module {
# Log a message
log(level: LogLevel!, message: String!, context: String): LogEntry!

trace(message: String!, context: String): LogEntry!
debug(message: String!, context: String): LogEntry!
info(message: String!, context: String): LogEntry!
warn(message: String!, context: String): LogEntry!
error(message: String!, context: String): LogEntry!
fatal(message: String!, context: String): LogEntry!

# Change the minimum log level at runtime
setLogLevel(level: LogLevel!): Boolean!

# Get the current log level
getLogLevel: LogLevel!

# Get a specific log entry by ID
getLog(id: Int!): LogEntry

# Get a list of logs, optionally by log level
getLogs(level: LogLevel): [LogEntry!]!
}

enum LogLevel {
DEBUG
INFO
WARN
ERROR
TRACE
DEBUG
INFO
WARN
ERROR
FATAL
}

type Module {
log(
type LogEntry {
id: Int!
timestamp: String! # ISO 8601 format
level: LogLevel!
message: String!
): Boolean!
context: String
}
```

## Usage
```graphql
#import * from "ens/wraps.eth:logger@1.0.0"
#import * from "ens/wraps.eth:logging@1.0.0"
```

And implement the `log` method within your programming language of choice.
And implement the interface methods within your programming language of choice.

## Known Implementations
* [`@polywrap/logger-plugin-js`](https://www.npmjs.com/package/@polywrap/logger-plugin-js) - JavaScript Plugin
## Source Code
[Link](https://github.com/polywrap/std/logging)

## Known Aggregators
* `logging-wrapper` @ [`ens/wraps.eth:[email protected]`](https://wrappers.io/v/ens/wraps.eth:logging@1.0.0) - Wasm Wrapper
## Known Implementations
[Link](https://github.com/polywrap/logging/tree/master/implementations)
Loading