Search in sources :

Example 11 with LoggingContext

use of io.cdap.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHttpHandler method getLogs.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs")
public void getLogs(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("start") @DefaultValue("-1") long fromTimeSecsParam, @QueryParam("stop") @DefaultValue("-1") long toTimeSecsParam, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws Exception {
    ensureVisibilityOnProgram(namespaceId, appId, programType, programId);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType));
    doGetLogs(logReader, responder, loggingContext, fromTimeSecsParam, toTimeSecsParam, escape, filterStr, null, format, suppress);
}
Also used : LoggingContext(io.cdap.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 12 with LoggingContext

use of io.cdap.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHttpHandler method runIdNext.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/runs/{run-id}/logs/next")
public void runIdNext(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @PathParam("run-id") String runId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws Exception {
    ensureVisibilityOnProgram(namespaceId, appId, programType, programId);
    ProgramType type = ProgramType.valueOfCategoryName(programType);
    ProgramRunId programRunId = new ProgramRunId(namespaceId, appId, type, programId, runId);
    RunRecordDetail runRecord = getRunRecordMeta(programRunId);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContextWithRunId(programRunId, runRecord.getSystemArgs());
    doNext(logReader, responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, runRecord, format, suppress);
}
Also used : LoggingContext(io.cdap.cdap.common.logging.LoggingContext) RunRecordDetail(io.cdap.cdap.internal.app.store.RunRecordDetail) ProgramType(io.cdap.cdap.proto.ProgramType) ProgramRunId(io.cdap.cdap.proto.id.ProgramRunId) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 13 with LoggingContext

use of io.cdap.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHttpHandler method sysNext.

@GET
@Path("/system/{component-id}/{service-id}/logs/next")
public void sysNext(HttpRequest request, HttpResponder responder, @PathParam("component-id") String componentId, @PathParam("service-id") String serviceId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws Exception {
    accessEnforcer.enforce(NamespaceId.SYSTEM, authenticationContext.getPrincipal(), StandardPermission.GET);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(Id.Namespace.SYSTEM.getId(), componentId, serviceId);
    doNext(logReader, responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress);
}
Also used : LoggingContext(io.cdap.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 14 with LoggingContext

use of io.cdap.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHttpHandler method sysPrev.

@GET
@Path("/system/{component-id}/{service-id}/logs/prev")
public void sysPrev(HttpRequest request, HttpResponder responder, @PathParam("component-id") String componentId, @PathParam("service-id") String serviceId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws Exception {
    accessEnforcer.enforce(NamespaceId.SYSTEM, authenticationContext.getPrincipal(), StandardPermission.GET);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(Id.Namespace.SYSTEM.getId(), componentId, serviceId);
    doPrev(logReader, responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress);
}
Also used : LoggingContext(io.cdap.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 15 with LoggingContext

use of io.cdap.cdap.common.logging.LoggingContext in project cdap by caskdata.

the class LogHttpHandler method next.

@GET
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/logs/next")
public void next(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId, @QueryParam("max") @DefaultValue("50") int maxEvents, @QueryParam("fromOffset") @DefaultValue("") String fromOffsetStr, @QueryParam("escape") @DefaultValue("true") boolean escape, @QueryParam("filter") @DefaultValue("") String filterStr, @QueryParam("format") @DefaultValue("text") String format, @QueryParam("suppress") List<String> suppress) throws Exception {
    ensureVisibilityOnProgram(namespaceId, appId, programType, programId);
    LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(namespaceId, appId, programId, ProgramType.valueOfCategoryName(programType));
    doNext(logReader, responder, loggingContext, maxEvents, fromOffsetStr, escape, filterStr, null, format, suppress);
}
Also used : LoggingContext(io.cdap.cdap.common.logging.LoggingContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

LoggingContext (io.cdap.cdap.common.logging.LoggingContext)74 Test (org.junit.Test)20 WorkerLoggingContext (io.cdap.cdap.logging.context.WorkerLoggingContext)18 GET (javax.ws.rs.GET)18 Path (javax.ws.rs.Path)18 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)16 ServiceLoggingContext (io.cdap.cdap.common.logging.ServiceLoggingContext)14 Injector (com.google.inject.Injector)12 LogAppenderInitializer (io.cdap.cdap.logging.appender.LogAppenderInitializer)12 LoggingTester (io.cdap.cdap.logging.appender.LoggingTester)12 File (java.io.File)12 Configuration (org.apache.hadoop.conf.Configuration)12 Cancellable (org.apache.twill.common.Cancellable)10 FileLogReader (io.cdap.cdap.logging.read.FileLogReader)8 LogEvent (io.cdap.cdap.logging.read.LogEvent)8 ProgramRunId (io.cdap.cdap.proto.id.ProgramRunId)8 Logger (org.slf4j.Logger)8 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)6 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)6 RunRecordDetail (io.cdap.cdap.internal.app.store.RunRecordDetail)6