Skip to content

fix: Make use LOG_LEVEL variable #370

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

Merged
merged 1 commit into from
Apr 3, 2025
Merged
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
4 changes: 2 additions & 2 deletions adala/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async def arun(
"When using asynchronous run with `agent.arun()`, the runtime must be an AsyncRuntime."
)
else:
print(f"Using runtime {type(runtime)}")
logger.info("Using runtime %s", type(runtime))

if input is None:
if self.environment is None:
Expand All @@ -276,7 +276,7 @@ async def arun(
batch_size=runtime.batch_size
)
if data_batch.empty:
print_text("No more data in the environment. Exiting.")
logger.info("No more data in the environment. Exiting.")
break
except Exception as e:
# TODO: environment should raise a specific exception + log error
Expand Down
9 changes: 6 additions & 3 deletions adala/skills/skillset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from pydantic import BaseModel, model_validator, field_validator
from abc import ABC, abstractmethod
from typing import List, Union, Dict, Any, Optional, Mapping, Type
Expand All @@ -18,6 +19,8 @@
SynthesisSkill,
)

logger = logging.getLogger(__name__)


class SkillSet(BaseModel, ABC):
"""
Expand Down Expand Up @@ -199,7 +202,7 @@ def apply(
for i, skill_name in enumerate(skill_sequence):
skill = self.skills[skill_name]
# use input dataset for the first node in the pipeline
print_text(f"Applying skill: {skill_name}")
logger.info("Applying skill: %s", skill_name)
skill_output = skill.apply(skill_input, runtime)

# Commented out to not log customer data. Can be used when debugging if needed
Expand Down Expand Up @@ -248,7 +251,7 @@ async def aapply(
for i, skill_name in enumerate(skill_sequence):
skill = self.skills[skill_name]
# use input dataset for the first node in the pipeline
print_text(f"Applying skill: {skill_name}")
logger.info("Applying skill: %s", skill_name)
skill_output = await skill.aapply(skill_input, runtime)

# Commented out to not log customer data. Can be used when debugging if needed
Expand Down Expand Up @@ -322,7 +325,7 @@ def apply(
for i, skill_name in enumerate(skill_sequence):
skill = self.skills[skill_name]
# use input dataset for the first node in the pipeline
print_text(f"Applying skill: {skill_name}")
logger.info("Applying skill: %s", skill_name)
skill_output = skill.apply(input, runtime)
skill_outputs.append(skill_output)
if not skill_outputs:
Expand Down
5 changes: 4 additions & 1 deletion server/log_middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import os
from logging import Formatter
from starlette.middleware.base import BaseHTTPMiddleware

Expand All @@ -20,11 +21,13 @@ def format(self, record):
return json.dumps(json_record)


LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()

logger = logging.root
handler = logging.StreamHandler()
handler.setFormatter(JsonFormatter())
logger.handlers = [handler]
logger.setLevel(logging.DEBUG)
logger.setLevel(getattr(logging, LOG_LEVEL, logging.INFO))
logging.getLogger("uvicorn.access").disabled = True


Expand Down