Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Steps to run this sample:

  1. Run a Temporal service.
  2. Run the following command to start the worker
go run slogadapter/worker/main.go
  1. Run the following command to start the example
go run slogadapter/starter/main.go
  1. Check worker logs in colorful JSON format:
{"time":"2023-10-06T14:16:30.511716-07:00","level":"INFO","source":{"function":"go.temporal.io/sdk/internal.(*AggregatedWorker).Start","file":"/Users/user/go/pkg/mod/go.temporal.io/[email protected]/internal/internal_worker.go","line":987},"msg":"Started Worker","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@"}
{"time":"2023-10-06T14:16:32.679875-07:00","level":"INFO","source":{"function":"github.com/temporalio/samples-go/slogadapter.Workflow","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":22},"msg":"Logging from workflow","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","Attempt":1,"name":"<param to log>"}
{"time":"2023-10-06T14:16:32.67998-07:00","level":"DEBUG","source":{"function":"go.temporal.io/sdk/internal.(*workflowEnvironmentImpl).ExecuteActivity","file":"/Users/user/go/pkg/mod/go.temporal.io/[email protected]/internal/internal_event_handlers.go","line":676},"msg":"ExecuteActivity","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","Attempt":1,"ActivityID":"5","ActivityType":"LoggingActivity"}
{"time":"2023-10-06T14:16:32.689103-07:00","level":"INFO","source":{"function":"github.com/temporalio/samples-go/slogadapter.LoggingActivity","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":45},"msg":"Executing LoggingActivity.","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","ActivityID":"5","ActivityType":"LoggingActivity","Attempt":1,"WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","activity":"LoggingActivity","name":"<param to log>"}
{"time":"2023-10-06T14:16:32.689144-07:00","level":"DEBUG","source":{"function":"github.com/temporalio/samples-go/slogadapter.LoggingActivity","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":46},"msg":"Debugging LoggingActivity.","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","ActivityID":"5","ActivityType":"LoggingActivity","Attempt":1,"WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","activity":"LoggingActivity","value":"important debug data"}
{"time":"2023-10-06T14:16:32.703167-07:00","level":"DEBUG","source":{"function":"go.temporal.io/sdk/internal.(*workflowEnvironmentImpl).ExecuteActivity","file":"/Users/user/go/pkg/mod/go.temporal.io/[email protected]/internal/internal_event_handlers.go","line":676},"msg":"ExecuteActivity","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","Attempt":1,"ActivityID":"11","ActivityType":"LoggingErrorAcctivity"}
{"time":"2023-10-06T14:16:32.70982-07:00","level":"WARN","source":{"function":"github.com/temporalio/samples-go/slogadapter.LoggingErrorAcctivity","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":52},"msg":"Ignore next error message. It is just for demo purpose.","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","ActivityID":"11","ActivityType":"LoggingErrorAcctivity","Attempt":1,"WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3"}
{"time":"2023-10-06T14:16:32.709847-07:00","level":"ERROR","source":{"function":"github.com/temporalio/samples-go/slogadapter.LoggingErrorAcctivity","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":53},"msg":"Unable to execute LoggingErrorAcctivity.","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","ActivityID":"11","ActivityType":"LoggingErrorAcctivity","Attempt":1,"WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","error":"random error"}
{"time":"2023-10-06T14:16:32.720006-07:00","level":"INFO","source":{"function":"github.com/temporalio/samples-go/slogadapter.Workflow","file":"/Users/user/Documents/Code/samples-go/slogadapter/workflow.go","line":37},"msg":"Workflow completed.","Namespace":"default","TaskQueue":"slog-logger","WorkerID":"11177@worker@","WorkflowType":"Workflow","WorkflowID":"slog_logger_workflow_id","RunID":"7666eddc-a124-445a-a085-2fd0e9a719e3","Attempt":1}