Documentation
¶
Overview ¶
Package calllog provides structured JSON logging for game API request/response pairs. Log files are automatically rotated at midnight in the PST8PDT timezone. Entries are split into two files: actions (mutations) and queries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Mutations = map[string]bool{ "accept_mission": true, "attack": true, "buy": true, "buy_insurance": true, "buy_listed_ship": true, "cancel_commission": true, "cancel_order": true, "cancel_ship_listing": true, "cloak": true, "commission_ship": true, "complete_mission": true, "craft": true, "create_buy_order": true, "create_faction": true, "create_sell_order": true, "deposit_items": true, "distress_signal": true, "dock": true, "faction_accept_ally": true, "faction_accept_peace": true, "faction_cancel_mission": true, "faction_create_buy_order": true, "faction_create_sell_order": true, "faction_declare_war": true, "faction_deposit_credits": true, "faction_deposit_items": true, "faction_invite": true, "faction_kick": true, "faction_post_mission": true, "faction_promote": true, "faction_propose_ally": true, "faction_propose_peace": true, "faction_remove_ally": true, "faction_set_enemy": true, "faction_submit_intel": true, "faction_submit_trade_intel": true, "faction_withdraw_credits": true, "faction_withdraw_items": true, "espionage": true, "fleet": true, "install_mod": true, "jettison": true, "join_faction": true, "jump": true, "leave_faction": true, "list_ship_for_sale": true, "loot_wreck": true, "mine": true, "modify_order": true, "name_ship": true, "refit_ship": true, "refuel": true, "release_tow": true, "reload": true, "repair": true, "repair_module": true, "salvage_wreck": true, "scan": true, "scrap_wreck": true, "self_destruct": true, "sell": true, "sell_ship": true, "sell_wreck": true, "send_gift": true, "set_home_base": true, "supply_commission": true, "survey_system": true, "switch_ship": true, "tow_wreck": true, "trade_accept": true, "trade_offer": true, "travel": true, "undock": true, "uninstall_mod": true, "use_item": true, "withdraw_items": true, }
Mutations is the set of WebSocket message types that are actions/mutations (as opposed to read-only queries). Derived from x-is-mutation in openapi.json.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
State StateSnapshot `json:"state"`
Request json.RawMessage `json:"request"`
Response json.RawMessage `json:"response"`
}
Entry represents a single log record written as one line of JSON.
type LocationInfo ¶
type LocationInfo struct {
System string `json:"system"`
POI string `json:"poi"`
Docked bool `json:"docked"`
Traveling bool `json:"traveling,omitempty"`
}
LocationInfo captures where the agent is.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes JSON log entries for API request/response pairs, splitting mutations into an "actions" log and everything else into a "queries" log. Both files rotate at midnight in the PST8PDT timezone.
func New ¶
New creates a Logger that writes to dir with the given filename prefix. mutations is the set of message types that are actions/mutations (logged to the actions file); all other types go to the queries file. Files are named {prefix}.actions.YYYYMMDD.log and {prefix}.queries.YYYYMMDD.log.
func (*Logger) Log ¶
func (l *Logger) Log(msgType string, snap StateSnapshot, request, response json.RawMessage) error
Log writes a request/response pair to the appropriate log file (actions or queries) based on whether msgType is a mutation. If the PST8PDT date has changed since the last write to that file, the old file is flushed and closed, and a new one is created.
type ShipInfo ¶
type ShipInfo struct {
Name string `json:"name"`
ClassID string `json:"class_id"`
Hull float64 `json:"hull"`
MaxHull float64 `json:"max_hull"`
Shield float64 `json:"shield"`
MaxShield float64 `json:"max_shield"`
Fuel float64 `json:"fuel"`
MaxFuel float64 `json:"max_fuel"`
CargoUsed float64 `json:"cargo_used"`
CargoCapacity float64 `json:"cargo_capacity"`
Modules []string `json:"modules"`
}
ShipInfo captures the agent's ship state.
type StateSnapshot ¶
type StateSnapshot struct {
Timestamp string `json:"timestamp"`
Location LocationInfo `json:"location"`
Ship ShipInfo `json:"ship"`
}
StateSnapshot captures the agent's context at the time of a log entry.