Skip to content

Commit

Permalink
add: log to file instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Hungerarray committed Feb 3, 2025
1 parent 194ed78 commit 7cb523d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,5 @@ cython_debug/
.pypirc

__debug*

locator_log.json
10 changes: 7 additions & 3 deletions examples/appium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package main

import (
"fmt"
"log/slog"
"os"

locatr "github.com/vertexcover-io/locatr/golang"
appiumLocatr "github.com/vertexcover-io/locatr/golang/appium"
"github.com/vertexcover-io/locatr/golang/llm"
"github.com/vertexcover-io/locatr/golang/logger"
)

func main() {
logger.Level.Set(slog.LevelDebug)

llmClient, _ := llm.NewLlmClient(
llm.OpenAI, // (openai | anthropic),
os.Getenv("OPENAI_MODEL"),
Expand All @@ -19,14 +23,14 @@ func main() {
LlmClient: llmClient,
}
aLocatr, err := appiumLocatr.NewAppiumLocatr(
"https://device.pcloudy.com/appiumcloud/wd/hub",
"89ead025-4cf4-4c44-b723-feff1c3aa28f", bLocatr,
"http://localhost:4723",
"640daa1b-afdc-45a3-83fd-d0c37cffb3de", bLocatr,
)
if err != nil {
fmt.Println("failed creating appium locatr locatr", err)
return
}
desc := "This element is a textbox designed for user input, specifically for search queries. It is labeled for accessibility as \"Google Search\" and allows users to enter text. The textbox supports autocomplete features, enhancing the user experience by suggesting possible queries as the user types. It is configured to ignore capitalization and offers spell check capabilities. Additionally, it has a maximum length for input, ensuring submissions remain manageable. The role of the element is defined as a \"textbox,\" indicating its primary purpose for text entry."
desc := "This input element is designed for password entry, indicated by its type attribute set to \"password,\" which obscures the text entered for privacy. It requires user input, as denoted by the \"required\" attribute, ensuring that users do not submit the form without filling out this field. The placeholder text prompts users to \"Enter your password,\" guiding them on the expected input. This input is commonly used within forms where sensitive data is collected, such as registration or login forms."
l, err := aLocatr.GetLocatrStr(desc)
if err != nil {
fmt.Println("error getting locatr", err)
Expand Down
6 changes: 5 additions & 1 deletion golang/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ func newLogger() *slog.Logger {
opts := &slog.HandlerOptions{
Level: Level,
}
return slog.New(slog.NewJSONHandler(os.Stdout, opts))
log_file, err := os.Create("locator_log.json")
if err != nil {
panic("failed to create log file")
}
return slog.New(slog.NewJSONHandler(log_file, opts))
}

var Logger = newLogger()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exclude = [

[project]
name = "test_locatr"
version = "0.38.0"
version = "0.40.0"
description = "Get HTML/XML elements css/xpath selectors using natural language."
readme = "python_client/README.md"
requires-python = ">=3.9"
Expand Down

0 comments on commit 7cb523d

Please sign in to comment.